function b_news_topics_show() { global $xoopsDB, $storytopic; $block = array(); include_once XOOPS_ROOT_PATH . "/class/xoopstopic.php"; $xt = new XoopsTopic($xoopsDB->prefix("topics")); $jump = XOOPS_URL . "/modules/news/index.php?storytopic="; $storytopic = !empty($storytopic) ? intval($storytopic) : 0; ob_start(); $xt->makeTopicSelBox(1, $storytopic, "storytopic", "location=\"" . $jump . "\"+this.options[this.selectedIndex].value"); $block['selectbox'] = ob_get_contents(); ob_end_clean(); return $block; }
function &getCategories($respond = true) { if (!$this->_checkUser($this->params[1], $this->params[2])) { $this->response->add(new XoopsXmlRpcFault(104)); } else { include_once XOOPS_ROOT_PATH . '/class/xoopstopic.php'; $this->db =& XoopsDatabaseFactory::getDatabaseConnection(); $xt = new XoopsTopic($db->prefix('topics')); $ret = $xt->getTopicsList(); if (!$respond) { return $ret; } else { if (count($ret) == 0) { $this->response->add(new XoopsXmlRpcFault(106, 'Found 0 Entries')); } else { $arr = new XoopsXmlRpcArray(); foreach ($ret as $topic_id => $topic_vars) { $struct = new XoopsXmlRpcStruct(); $struct->add('categoryId', new XoopsXmlRpcString($topic_id)); $struct->add('categoryName', new XoopsXmlRpcString($topic_vars['title'])); $struct->add('categoryPid', new XoopsXmlRpcString($topic_vars['pid'])); $arr->add($struct); unset($struct); } $this->response->add($arr); } } } }
exit; } $op = 'form'; foreach ($HTTP_POST_VARS as $k => $v) { ${$k} = $v; } if (isset($HTTP_POST_VARS['preview'])) { $op = 'preview'; } elseif (isset($HTTP_POST_VARS['post'])) { $op = 'post'; } switch ($op) { case "preview": $myts =& MyTextSanitizer::getInstance(); // MyTextSanitizer object $xt = new XoopsTopic($xoopsDB->prefix("topics"), $HTTP_POST_VARS['topic_id']); include XOOPS_ROOT_PATH . '/header.php'; $p_subject = $myts->makeTboxData4Preview($subject); if ($xoopsUser && $xoopsUser->isAdmin($xoopsModule->getVar('mid'))) { $nohtml = isset($nohtml) ? intval($nohtml) : 0; } else { $nohtml = 1; } $html = empty($nohtml) ? 1 : 0; if (isset($nosmiley) && intval($nosmiley) > 0) { $nosmiley = 1; $smiley = 0; } else { $nosmiley = 0; $smiley = 1; }
function getCategories($respond = true) { global $xoopsDB; if (!$this->_checkUser($this->params[1], $this->params[2])) { $this->response->add(new XoopsXmlRpcFault(104)); } else { if (!XoopsLoad::loadFile(\XoopsBaseConfig::get('root-path') . '/class/xoopstopic.php', true)) { $this->response->add(new XoopsXmlRpcFault(103)); return; } //$this->db = xoopsDB; $xt = new XoopsTopic($xoopsDB->prefix('topics')); $ret = $xt->getTopicsList(); if (!$respond) { return $ret; } else { if (count($ret) == 0) { $this->response->add(new XoopsXmlRpcFault(106, 'Found 0 Entries')); } else { $arr = new XoopsXmlRpcArray(); foreach ($ret as $topic_id => $topic_vars) { $struct = new XoopsXmlRpcStruct(); $struct->add('categoryId', new XoopsXmlRpcString($topic_id)); $struct->add('categoryName', new XoopsXmlRpcString($topic_vars['title'])); $struct->add('categoryPid', new XoopsXmlRpcString($topic_vars['pid'])); $arr->add($struct); unset($struct); } $this->response->add($arr); } } } }
function delTopic() { if (!isset($_REQUEST['topic_id']) || $_REQUEST['topic_id'] == 0) { redirect_header('index.php?op=topicsmanager', 3, _AMS_AM_NOTOPICSELECTED); } global $xoopsDB, $xoopsModule; if (!isset($_POST['ok'])) { echo "<h4>" . _AMS_AM_CONFIG . "</h4>"; $xt = new XoopsTopic($xoopsDB->prefix("ams_topics"), intval($_GET['topic_id'])); xoops_confirm(array('op' => 'delTopic', 'topic_id' => intval($_GET['topic_id']), 'ok' => 1), 'index.php', _AMS_AM_WAYSYWTDTTAL . '<br />' . $xt->topic_title('S')); } else { $xt = new XoopsTopic($xoopsDB->prefix("ams_topics"), intval($_POST['topic_id'])); // get all subtopics under the specified topic $topic_arr = $xt->getAllChildTopics(); array_push($topic_arr, $xt); foreach ($topic_arr as $eachtopic) { // get all stories in each topic $story_arr = AmsStory::getByTopic($eachtopic->topic_id()); foreach ($story_arr as $eachstory) { if (false != $eachstory->delete()) { xoops_comment_delete($xoopsModule->getVar('mid'), $eachstory->storyid()); xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'story', $eachstory->storyid()); } } // all stories for each topic is deleted, now delete the topic data $eachtopic->delete(); // Delete also the notifications and permissions xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'category', $eachtopic->topic_id); xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'ams_approve', $eachtopic->topic_id); xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'ams_submit', $eachtopic->topic_id); xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'ams_view', $eachtopic->topic_id); } redirect_header('index.php?op=topicsmanager', 1, _AMS_AM_DBUPDATED); exit; } }
function b_news_randomnews_edit($options) { global $xoopsDB; $form = "" . _MB_NEWS_ORDER . " <select name='options[]'>"; $form .= "<option value='published'"; if ($options[0] == "published") { $form .= " selected='selected'"; } $form .= ">" . _MB_NEWS_DATE . "</option>\n"; $form .= "<option value='counter'"; if ($options[0] == "counter") { $form .= " selected='selected'"; } $form .= ">" . _MB_NEWS_HITS . "</option>"; $form .= "<option value='rating'"; if ($options[0] == "rating") { $form .= " selected='selected'"; } $form .= ">" . _MB_NEWS_RATE . "</option>"; $form .= "</select>\n"; $form .= " " . _MB_NEWS_DISP . " <input type='text' name='options[]' value='" . $options[1] . "'/> " . _MB_NEWS_ARTCLS . ""; $form .= " <br><br />" . _MB_NEWS_CHARS . " <input type='text' name='options[]' value='" . $options[2] . "'/> " . _MB_NEWS_LENGTH . "<br /><br />"; $form .= _MB_NEWS_TEASER . " <input type='text' name='options[]' value='" . $options[3] . "' />" . _MB_NEWS_LENGTH; $form .= "<br /><br />" . _MB_SPOTLIGHT_TOPIC . "<br /><select id='options[4]' name='options[]' multiple='multiple'>"; include_once XOOPS_ROOT_PATH . "/class/xoopsstory.php"; $xt = new XoopsTopic($xoopsDB->prefix("topics")); $alltopics = $xt->getTopicsList(); $alltopics[0]['title'] = _MB_SPOTLIGHT_ALL_TOPICS; ksort($alltopics); $size = count($options); foreach ($alltopics as $topicid => $topic) { $sel = ""; for ($i = 4; $i < $size; $i++) { if ($options[$i] == $topicid) { $sel = " selected='selected'"; } } $form .= "<option value='{$topicid}'{$sel}>" . $topic['title'] . "</option>"; } $form .= "</select><br />"; return $form; }
function store() { $mode = empty($this->topic_id) ? 'insert' : 'udpate'; parent::store(); if ($mode == 'insert') { $this->topic_id = $this->db->getInsertId(); $this->db->query("UPDATE " . $this->table . " SET topic_created=UNIX_TIMESTAMP(),topic_modified=UNIX_TIMESTAMP() WHERE topic_id=" . $this->topic_id); //ver3.0 $gperm =& BulletinGP::getInstance($this->mydirname); $result = $gperm->insertdefaultpermissions($this->topic_id); } else { $this->db->query("UPDATE " . $this->table . " SET topic_modified=UNIX_TIMESTAMP() WHERE topic_id=" . $this->topic_id); } }
$selected = array('', '', ''); $selected[$permtoset - 1] = ' selected'; echo "<form method='post' name='fselperm' action='groupperms.php'><select name='permtoset' onChange='javascript: document.fselperm.submit()'><option value='1'" . $selected[0] . ">" . _AM_APPROVEFORM . "</option><option value='2'" . $selected[1] . ">" . _AM_SUBMITFORM . "</option><option value='3'" . $selected[2] . ">" . _AM_VIEWFORM . "</option></select> <input type='submit' name='go'></form>"; $module_id = $xoopsModule->getVar('mid'); switch ($permtoset) { case 1: $title_of_form = _AM_APPROVEFORM; $perm_name = 'news_approve'; $perm_desc = _AM_APPROVEFORM_DESC; break; case 2: $title_of_form = _AM_SUBMITFORM; $perm_name = 'news_submit'; $perm_desc = _AM_SUBMITFORM_DESC; break; case 3: $title_of_form = _AM_VIEWFORM; $perm_name = 'news_view'; $perm_desc = _AM_VIEWFORM_DESC; break; } $permform = new XoopsGroupPermForm($title_of_form, $module_id, $perm_name, $perm_desc, 'admin/groupperms.php'); $xt = new XoopsTopic($xoopsDB->prefix('topics')); $alltopics =& $xt->getTopicsList(); foreach ($alltopics as $topic_id => $topic) { $permform->addItem($topic_id, $topic['title'], $topic['pid']); } echo $permform->render(); echo "<br /><br /><br /><br />\n"; unset($permform); xoops_cp_footer();
if (isset($HTTP_GET_VARS['storynum'])) { $xoopsOption['storynum'] = intval($HTTP_GET_VARS['storynum']); if ($xoopsOption['storynum'] > 30) { $xoopsOption['storynum'] = $xoopsModuleConfig['storyhome']; } } else { $xoopsOption['storynum'] = $xoopsModuleConfig['storyhome']; } if (isset($HTTP_GET_VARS['start'])) { $start = intval($HTTP_GET_VARS['start']); } else { $start = 0; } if ($xoopsModuleConfig['displaynav'] == 1) { $xoopsTpl->assign('displaynav', true); $xt = new XoopsTopic($xoopsDB->prefix('topics')); ob_start(); $xt->makeTopicSelBox(1, $xoopsOption['storytopic'], 'storytopic'); $topic_select = ob_get_contents(); ob_end_clean(); $xoopsTpl->assign('topic_select', $topic_select); $storynum_options = ''; for ($i = 5; $i <= 30; $i = $i + 5) { $sel = ''; if ($i == $xoopsOption['storynum']) { $sel = ' selected="selected"'; } $storynum_options .= '<option value="' . $i . '"' . $sel . '>' . $i . '</option>'; } $xoopsTpl->assign('storynum_options', $storynum_options); } else {
function delTopic() { global $xoopsDB, $xoopsModule; if (!isset($_POST['ok'])) { xoops_cp_header(); echo '<h4>' . _AM_CONFIG . '</h4>'; $xt = new XoopsTopic($xoopsDB->prefix('topics'), intval($_GET['topic_id'])); xoops_confirm(array('op' => 'delTopic', 'topic_id' => intval($_GET['topic_id']), 'ok' => 1), 'index.php', _AM_WAYSYWTDTTAL . '<br />' . $xt->topic_title('S')); } else { xoops_cp_header(); $xt = new XoopsTopic($xoopsDB->prefix('topics'), intval($_POST['topic_id'])); if (isset($_SESSION['items_count'])) { $_SESSION['items_count'] = -1; } // get all subtopics under the specified topic $topic_arr = $xt->getAllChildTopics(); array_push($topic_arr, $xt); foreach ($topic_arr as $eachtopic) { // get all stories in each topic $story_arr = NewsStory::getByTopic($eachtopic->topic_id()); foreach ($story_arr as $eachstory) { if (false != $eachstory->delete()) { xoops_comment_delete($xoopsModule->getVar('mid'), $eachstory->storyid()); xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'story', $eachstory->storyid()); } } // all stories for each topic is deleted, now delete the topic data $eachtopic->delete(); // Delete also the notifications and permissions xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'category', $eachtopic->topic_id); xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'news_approve', $eachtopic->topic_id); xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'news_submit', $eachtopic->topic_id); xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'news_view', $eachtopic->topic_id); } news_updateCache(); redirect_header('index.php?op=topicsmanager', 1, _AM_DBUPDATED); exit; } }
?> <table><tr><td> <form action='<?php echo $submit_page; ?> ' method='post' name='coolsus'> <?php echo "<p><b>" . _AM_TITLE . "</b><br />"; echo "<input type='text' name='title' id='title' value='"; if (isset($title)) { echo $title; } echo "' size='70' maxlength='80' />"; echo "</p><p>"; echo "<b>" . _AM_TOPIC . "</b> "; $xt = new XoopsTopic($xoopsDB->prefix("topics")); if (isset($topicid)) { $xt->makeTopicSelBox(0, $topicid, "topicid"); } else { $xt->makeTopicSelBox(0, 0, "topicid"); } echo "<br /><b>" . _AM_TOPICDISPLAY . "</b> <input type='radio' name='topicdisplay' value='1'"; if (!isset($topicdisplay) || $topicdisplay == 1) { echo " checked='checked'"; } echo " />" . _AM_YES . " <input type='radio' name='topicdisplay' value='0'"; if (empty($topicdisplay)) { echo " checked='checked'"; } echo " />" . _AM_NO . " "; echo "<b>" . _AM_TOPICALIGN . "</b> <select name='topicalign'>\n";
function addTopic() { global $xoopsDB, $_POST; $xt = new XoopsTopic($xoopsDB->prefix("topics")); if (!$xt->topicExists($_POST['topic_pid'], $_POST['topic_pid'])) { $xt->setTopicPid($_POST['topic_pid']); if (empty($_POST['topic_title'])) { redirect_header("index.php?op=topicsmanager", 2, _AM_ERRORTOPICNAME); } $xt->setTopicTitle($_POST['topic_title']); if (isset($_POST['topic_imgurl']) && $_POST['topic_imgurl'] != "") { $xt->setTopicImgurl($_POST['topic_imgurl']); } $xt->store(); $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 { echo "Topic exists!"; } exit; }
/** * Add pages to $this->pages from a topic tree * * @param XoopsTopic $topic * @param int $parentid key to start from * @param int $level * @param int $offset integer added to location * * @return void */ function traverseTopic($topic, $parentid = 0, $level = 0) { $subtopics =& $topic->getFirstChildTopics(); $level++; foreach (array_keys($subtopics) as $i) { $this->pages[] = array('location' => $subtopics[$i]->topic_id(), 'name' => $subtopics[$i]->topic_title(), 'level' => $level); $this->traverseTopic($subtopics[$i], $subtopics[$i]->topic_pid(), $level); } }
function store() { $mode = empty($this->topic_id) ? 'insert' : 'udpate'; parent::store(); if ($mode == 'insert') { $this->topic_id = $this->db->getInsertId(); $this->db->query("UPDATE " . $this->table . " SET topic_created=UNIX_TIMESTAMP(),topic_modified=UNIX_TIMESTAMP() WHERE topic_id=" . $this->topic_id); } else { $this->db->query("UPDATE " . $this->table . " SET topic_modified=UNIX_TIMESTAMP() WHERE topic_id=" . $this->topic_id); } }