Esempio n. 1
0
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;
    }
}
Esempio n. 2
0
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;
    }
}
Esempio n. 3
0
function modTopic()
{
    global $xoopsDB, $xoopsConfig;
    global $xoopsModule;
    $xt = new XoopsTopic($xoopsDB->prefix("topics"), $_POST['topic_id']);
    $topics_array = XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . "/modules/news/images/topics/");
    xoops_cp_header();
    echo "<h4>" . _AM_CONFIG . "</h4>";
    // $xoopsModule->printAdminMenu();
    // echo "<br />";
    echo "<table width='100%' border='0' cellspacing='1' class='outer'><tr><td class=\"odd\">";
    echo "<h4>" . _AM_MODIFYTOPIC . "</h4><br />";
    if ($xt->topic_imgurl()) {
        echo "<div style='text-align: right;'><img src='" . XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/images/topics/" . $xt->topic_imgurl() . "'></div>";
    }
    echo "<form action='index.php' method='post'>";
    echo "<b>" . _AM_TOPICNAME . "</b>&nbsp;" . _AM_MAX40CHAR . "<br /><input type='text' name='topic_title' size='20' maxlength='40' value='" . $xt->topic_title('E') . "' /><br />";
    echo "<b>" . _AM_TOPICIMG . "</b>&nbsp;(" . sprintf(_AM_IMGNAEXLOC, "modules/" . $xoopsModule->dirname() . "/images/topics/") . ")<br />" . _AM_FEXAMPLE . "<br />";
    // echo "<input type='text' name='topic_imgurl' size='20' maxlength='20' value='".$xt->topic_imgurl()."' /><br />\n";
    echo "<select size='1' name='topic_imgurl'>";
    echo "<option value=' '>------</option>";
    foreach ($topics_array as $image) {
        if ($image == $xt->topic_imgurl()) {
            $opt_selected = "selected='selected'";
        } else {
            $opt_selected = "";
        }
        echo "<option value='" . $image . "' {$opt_selected}>" . $image . "</option>";
    }
    echo "</select><br />";
    echo "<b>" . _AM_PARENTTOPIC . "<b><br />\n";
    $xt->makeTopicSelBox(1, $xt->topic_pid(), "topic_pid");
    echo "\n<br /><br />";
    echo "<input type='hidden' name='topic_id' value='" . $xt->topic_id() . "' />\n";
    echo "<input type='hidden' name='op' value='modTopicS' />";
    echo "<input type='submit' value='" . _AM_SAVECHANGE . "' />&nbsp;<input type='button' value='" . _AM_DEL . "' onclick='location=\"index.php?topic_pid=" . $xt->topic_pid() . "&amp;topic_id=" . $xt->topic_id() . "&amp;op=delTopic\"' />\n";
    echo "&nbsp;<input type='button' value='" . _AM_CANCEL . "' onclick='javascript:history.go(-1)' />\n";
    echo "</form>";
    echo "</td></tr></table>";
}