Пример #1
0
/**
* Adds PHP blocks and scans all the items supported by the Tag plugin
*/
function plugin_postinstall_tag($pi_name)
{
    global $_CONF, $_TABLES, $_USER, $_TAG_CONF, $LANG_TAG;
    require_once dirname(__FILE__) . '/functions.inc';
    if (is_callable('COM_createHTMLDocument')) {
        // Adds a tag cloud block to the site
        $sql = "INSERT INTO {$_TABLES['blocks']} " . "  (is_enabled, name, type, title, blockorder, onleft, " . "  phpblockfn, owner_id, group_id, perm_owner, perm_group, " . "  perm_members, perm_anon) " . "VALUES (1, '" . addslashes($_TAG_CONF['default_block_name']) . "', 'phpblock', '" . addslashes($LANG_TAG['default_block_title']) . "', 1, 0, 'phpblock_tag_cloud', '" . addslashes($_USER['uid']) . "', 1, 3, 3, 2, 2)";
        DB_query($sql);
        $bid = DB_insertId();
        $sql = "INSERT INTO {$_TABLES['topic_assignments']} " . "  (tid, type, id, inherit, tdefault) " . "VALUES ('all', 'block', {$bid}, 1, 0) ";
        DB_query($sql);
        // Adds a tag menu block to the site
        $sql = "INSERT INTO {$_TABLES['blocks']} (is_enabled, name, type, title, " . "  blockorder, onleft, phpblockfn, owner_id, group_id, " . "  perm_owner, perm_group, perm_members, perm_anon) " . "VALUES (1, '" . addslashes($_TAG_CONF['default_block_name_menu']) . "', 'phpblock', '" . addslashes($LANG_TAG['default_block_title_menu']) . "', 1, 1, 'phpblock_tag_menu', '" . addslashes($_USER['uid']) . "', 1, 3, 3, 2, 2)";
        DB_query($sql);
        $bid = DB_insertId();
        $sql = "INSERT INTO {$_TABLES['topic_assignments']} " . "  (tid, type, id, inherit, tdefault) " . "VALUES ('all', 'block', {$bid}, 1, 0) ";
        DB_query($sql);
    } else {
        // Adds a tag cloud block to the site
        $sql = "INSERT INTO {$_TABLES['blocks']} " . "  (is_enabled, name, type, title, tid, blockorder, onleft, " . "  phpblockfn, owner_id, group_id, perm_owner, perm_group, " . "  perm_members, perm_anon) " . "VALUES (1, '" . addslashes($_TAG_CONF['default_block_name']) . "', 'phpblock', '" . addslashes($LANG_TAG['default_block_title']) . "', 'all', '1', '0', 'phpblock_tag_cloud', '" . addslashes($_USER['uid']) . "', '1', '3', '3', '2', '2')";
        DB_query($sql);
        // Adds a tag menu block to the site
        $sql = "INSERT INTO {$_TABLES['blocks']} (is_enabled, name, type, title, " . "  tid, blockorder, onleft, phpblockfn, owner_id, group_id, " . "  perm_owner, perm_group, perm_members, perm_anon) " . "VALUES ('1', '" . addslashes($_TAG_CONF['default_block_name_menu']) . "', 'phpblock', '" . addslashes($LANG_TAG['default_block_title_menu']) . "', 'all', '1', '1', 'phpblock_tag_menu', '" . addslashes($_USER['uid']) . "', '1', '3', '3', '2', '2')";
        DB_query($sql);
    }
    // Scans all contents for tags
    TAG_scanAll();
    return TRUE;
}
Пример #2
0
 function doDelete()
 {
     global $_TABLES, $LANG_TAG;
     $submit = TAG_post('submit');
     if ($submit == $LANG_TAG['add']) {
         $this->doAdd();
         return;
     }
     $words = TAG_post('words');
     if (!is_array($words) or count($words) === 0) {
         return '';
     }
     /**
      * Deletes a bad word from DB
      */
     $words4db = array_map('addslashes', $words);
     $words4db = "('" . implode("','", $words4db) . "')";
     $sql = "DELETE FROM {$_TABLES['tag_badwords']} " . "WHERE (badword IN " . $words4db . ")";
     $result = DB_query($sql);
     /**
      * Rescans articles and staticpages for tags
      */
     DB_query("DELETE FROM {$_TABLES['tag_list']} ");
     DB_query("DELETE FROM {$_TABLES['tag_map']} ");
     TAG_scanAll();
     return DB_error() ? TAG_str('delete_fail') : TAG_str('delete_success');
 }