Ejemplo n.º 1
0
function TagsMain()
{
    loadtemplate('Tagging');
    loadLanguage('Tagging');
    $subActions = array('addtag' => 'TaggingSystem_Add', 'submittag' => 'TaggingSystem_Submit', 'deletetag' => 'TaggingSystem_Delete', 'admin' => 'TagsSettings', 'admin2' => 'TagsSettings2', 'cleanup' => 'TagCleanUp');
    if (!empty($subActions[@$_GET['sa']])) {
        $subActions[$_GET['sa']]();
    } else {
        ViewTags();
    }
}
Ejemplo n.º 2
0
function TagsMain()
{
    // Load the main Tags template
    loadtemplate('Tags2');
    // Load the language files
    if (loadlanguage('Tags') == false) {
        loadLanguage('Tags', 'english');
    }
    // Tags actions
    $subActions = array('suggest' => 'SuggestTag', 'suggest2' => 'SuggestTag2', 'addtag' => 'AddTag', 'addtag2' => 'AddTag2', 'deletetag' => 'DeleteTag', 'admin' => 'TagsSettings', 'admin2' => 'TagsSettings2', 'cleanup' => 'TagCleanUp');
    // Follow the sa or just go to main links index.
    if (!empty($subActions[@$_GET['sa']])) {
        $subActions[$_GET['sa']]();
    } else {
        ViewTags();
    }
}
Ejemplo n.º 3
0
function ViewAllTags($displaytags = 0, $sort = 0)
{
    global $context, $mbname, $txt, $db_prefix;
    if (!allowedTo('smftags_manage')) {
        fatal_error($txt['cannot_smftags_manage'], false);
    }
    $render = true;
    if (!empty($_REQUEST['todo'])) {
        $idarray = array_map('intval', array_keys($_REQUEST['tag']));
        if (in_array($_REQUEST['todo'], array('move', 'merge'))) {
            $act = $_REQUEST['todo'];
            $context['smftags_list'] = array_map('intval', array_keys($_REQUEST['tag']));
            $context['sub_template'] = 'viewall2';
            $context['page_title'] = $mbname . ' - ' . $txt['smftags_act_' . $act];
            $render = false;
            filltags(0, $context['smftags_list']);
            // hacky fix: move any orphaned tags to the root
            foreach ($context['tags']['by_parent'] as $parent => $children) {
                foreach ($children as $i => $child) {
                    $foundtags[$child[0]] = 1;
                }
            }
            if (!isset($context['tags']['by_parent'][0])) {
                $context['tags']['by_parent'][0] = array();
            }
            foreach ($context['tags']['by_parent'] as $parent => $children) {
                if ($parent > 0 && !isset($foundtags[$parent])) {
                    $context['tags']['by_parent'][0] = array_merge($context['tags']['by_parent'][0], $context['tags']['by_parent'][$parent]);
                    unset($context['tags']['by_parent'][$parent]);
                }
            }
            unset($foundtags);
            ViewTags();
        } else {
            if (in_array($_REQUEST['todo'], array('untaggable', 'taggable', 'unapprove'))) {
                $set = $_REQUEST['todo'] == 'unapprove' ? 'approved = 0' : 'taggable = ' . ($_REQUEST['todo'] == 'taggable' ? '1' : '0');
                $dbresult = db_query("\n                UPDATE {$db_prefix}tags\n                SET {$set} \n                WHERE `ID_TAG` IN (" . implode(",", $idarray) . ")", __FILE__, __LINE__);
                $context['tags']['modifiedtxt'] = sprintf($txt['smftags_success_' . strtolower($_REQUEST['todo'])], count($idarray));
            } else {
                if (in_array($_REQUEST['todo'], array('delete'))) {
                    $dbresult = db_query("\n                DELETE t, l FROM {$db_prefix}tags AS t\n                LEFT JOIN {$db_prefix}tags_log AS l ON t.`ID_TAG` = l.`ID_TAG`\n                WHERE t.`ID_TAG` IN (" . implode(",", $idarray) . ")", __FILE__, __LINE__);
                    $context['tags']['modifiedtxt'] = sprintf($txt['smftags_success_delete'], count($idarray), db_affected_rows());
                }
            }
        }
    } else {
        if (isset($_REQUEST['move']) || isset($_REQUEST['merge'])) {
            $master = (int) substr($_REQUEST['master'], 4, -1);
            $slaves = array_map('intval', explode(',', $_REQUEST['slaves']));
            // it's futile trying to merge/move tags to themselves
            while (in_array($master, $slaves)) {
                unset($slaves[array_search($master, $slaves)]);
            }
            if (isset($_REQUEST['move'])) {
                $dbresult = db_query("\n                UPDATE {$db_prefix}tags\n                SET `parent_id` = {$master}\n                WHERE `ID_TAG` IN (" . implode(",", $slaves) . ")", __FILE__, __LINE__);
                $context['tags']['modifiedtxt'] = sprintf($txt['smftags_success_move'], count($slaves));
            } else {
                if (isset($_REQUEST['merge'])) {
                    // ignore key collisions on (ID_TAG, ID_TOPIC)
                    $dbresult = db_query("\n                UPDATE IGNORE {$db_prefix}tags_log\n                SET `ID_TAG` = {$master}\n                WHERE `ID_TAG` IN (" . implode(",", $slaves) . ")", __FILE__, __LINE__);
                    $count = db_affected_rows();
                    $dbresult = db_query("\n                DELETE t.*, tl.* FROM {$db_prefix}tags AS t\n                LEFT JOIN {$db_prefix}tags_log AS tl ON tl.ID_TAG = t.ID_TAG\n                WHERE t.ID_TAG IN (" . implode(",", $slaves) . ")", __FILE__, __LINE__);
                    $count += db_affected_rows();
                    $context['tags']['modifiedtxt'] = sprintf($txt['smftags_success_merge'], count($slaves), $count);
                }
            }
        }
    }
    if ($render) {
        filltags(0, array(), 1);
        ViewTags($displaytags, $sort);
        $context['sub_template'] = 'viewall';
        $context['page_title'] = $mbname . ' - ' . $txt['smftags_all'];
    }
}