Пример #1
0
 /**
  * A very rough function to reconcile article tags
  *
  * Far to complete, like removing tags that have been removed from an article
  */
 function art_updateTag($mid = 0)
 {
     if (!@(include_once XOOPS_ROOT_PATH . "/modules/tag/include/functions.php")) {
         return false;
     }
     if (!($tag_handler =& tag_getTagHandler())) {
         return false;
     }
     $table_article = art_DB_prefix("article");
     $sql = "    SELECT art_id, art_keywords" . "    FROM " . art_DB_prefix("article") . "    WHERE art_time_publish >0" . "        AND art_keywords <> '' ";
     if (($result = $GLOBALS['xoopsDB']->query($sql)) == false) {
         //xoops_error($GLOBALS['xoopsDB']->error());
     }
     $mid = empty($mid) ? $GLOBALS["xoopsModule"]->getVar("mid") : $mid;
     while ($myrow = $GLOBALS['xoopsDB']->fetchArray($result)) {
         if (empty($myrow["art_keywords"])) {
             continue;
         }
         $tag_handler->updateByItem($myrow["art_keywords"], $myrow["art_id"], $mid);
     }
     return true;
 }
Пример #2
0
 function insert(&$object, $force = true)
 {
     if (!$object->getVar("topic_time")) {
         $object->setVar("topic_time", time());
     }
     if (!parent::insert($object, $force) || !$object->getVar("approved")) {
         return $object->getVar("topic_id");
     }
     require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.config.php";
     $newbbConfig = newbb_loadConfig();
     if (!empty($newbbConfig['do_tag']) && @(include_once XOOPS_ROOT_PATH . "/modules/tag/include/functions.php")) {
         if ($tag_handler = tag_getTagHandler()) {
             $tag_handler->updateByItem($object->getVar('topic_tags', 'n'), $object->getVar('topic_id'), "newbb");
         }
     }
     return $object->getVar("topic_id");
 }
Пример #3
0
/**
 * CBB 4.0, or newbb, the forum module for XOOPS project
 *
 * @copyright	The XOOPS Project http://xoops.sf.net
 * @license		http://www.fsf.org/copyleft/gpl.html GNU public license
 * @author		Taiwen Jiang (phppp or D.J.) <*****@*****.**>
 * @since		4.00
 * @version		$Id $
 * @package		module::newbb
 */
function xoops_module_update_newbb_v400(&$module)
{
    $stats_handler =& xoops_getmodulehandler('stats', 'newbb');
    $result = $GLOBALS['xoopsDB']->query("SELECT `forum_id`, `forum_topics`, `forum_posts` FROM " . $GLOBALS['xoopsDB']->prefix("bb_forums"));
    while ($row = $GLOBALS['xoopsDB']->fetchArray($result)) {
        $stats_handler->update($row["forum_id"], "topic", $row["forum_topics"]);
        $stats_handler->update($row["forum_id"], "post", $row["forum_posts"]);
    }
    $result = $GLOBALS['xoopsDB']->query("SELECT `forum_id`, SUM(topic_views) AS views FROM " . $GLOBALS['xoopsDB']->prefix("bb_topics") . " GROUP BY `forum_id`");
    while ($row = $GLOBALS['xoopsDB']->fetchArray($result)) {
        $stats_handler->update($row["forum_id"], "view", $row["views"]);
    }
    $result = $GLOBALS['xoopsDB']->query("SELECT `forum_id`, COUNT(*) AS digests FROM " . $GLOBALS['xoopsDB']->prefix("bb_topics") . " WHERE topic_digest = 1 GROUP BY `forum_id`");
    while ($row = $GLOBALS['xoopsDB']->fetchArray($result)) {
        $stats_handler->update($row["forum_id"], "digest", $row["digests"]);
    }
    $result = $GLOBALS['xoopsDB']->query("SELECT SUM(forum_topics) AS topics, SUM(forum_posts) AS posts FROM " . $GLOBALS['xoopsDB']->prefix("bb_forums"));
    while ($row = $GLOBALS['xoopsDB']->fetchArray($result)) {
        $stats_handler->update(-1, "topic", $row["topics"]);
        $stats_handler->update(-1, "post", $row["posts"]);
    }
    /*
    $GLOBALS['xoopsDB']->queryF(
    		"	INSERT INTO ".$GLOBALS['xoopsDB']->prefix("bb_stats").
    		"		(`id`, `value`, `type`, `period`, `time_update`, `time_format`)".
    		"	SELECT `forum_id`, `forum_topics`, '".NEWBB_STATS_TYPE_TOPIC."', '".NEWBB_STATS_PERIOD_TOTAL."', NOW() + 0, ''".
    		" 		FROM ".$GLOBALS['xoopsDB']->prefix("bb_forums")
    		);
    $GLOBALS['xoopsDB']->queryF(
    		"	INSERT INTO ".$GLOBALS['xoopsDB']->prefix("bb_stats").
    		"		(`id`, `value`, `type`, `period`, `time_update`, `time_format`)".
    		"	SELECT `forum_id`, `forum_posts`, '".NEWBB_STATS_TYPE_POST."', '".NEWBB_STATS_PERIOD_TOTAL."', NOW() + 0, ''".
    		" 		FROM ".$GLOBALS['xoopsDB']->prefix("bb_forums")
    		);
    $GLOBALS['xoopsDB']->queryF(
    		"	INSERT INTO ".$GLOBALS['xoopsDB']->prefix("bb_stats").
    		"		(`id`, `value`, `type`, `period`, `time_update`, `time_format`)".
    		"	SELECT `forum_id`, count(*), '".NEWBB_STATS_TYPE_DIGEST."', '".NEWBB_STATS_PERIOD_TOTAL."', NOW() + 0, ''".
    		" 		FROM ".$GLOBALS['xoopsDB']->prefix("bb_topics").
    		"		WHERE topic_digest = 1".
    		"		GROUP BY `forum_id`".
    		);
    $GLOBALS['xoopsDB']->queryF(
    		"	INSERT INTO ".$GLOBALS['xoopsDB']->prefix("bb_stats").
    		"		(`id`, `value`, `type`, `period`, `time_update`, `time_format`)".
    		"	SELECT `forum_id`, SUM(topic_views), '".NEWBB_STATS_TYPE_VIEW."', '".NEWBB_STATS_PERIOD_TOTAL."', NOW() + 0, ''".
    		" 		FROM ".$GLOBALS['xoopsDB']->prefix("bb_topics").
    		"		WHERE topic_digest = 1".
    		"		GROUP BY `forum_id`".
    		);
    */
    $sql = "\tUPDATE " . $GLOBALS['xoopsDB']->prefix("bb_posts_text") . " AS t, " . $GLOBALS['xoopsDB']->prefix("bb_posts") . " AS p" . "\tSET t.dohtml = p.dohtml, " . "\t\tt.dosmiley = p.dosmiley, " . "\t\tt.doxcode = p.doxcode, " . "\t\tt.doimage = p.doimage, " . "\t\tt.dobr = p.dobr" . "\tWHERE p.post_id =t.post_id ";
    if ($GLOBALS['xoopsDB']->queryF($sql)) {
        $sql = "\tALTER TABLE " . $GLOBALS['xoopsDB']->prefix("bb_posts") . "\t\tDROP `dohtml`," . "\t\tDROP `dosmiley`," . "\t\tDROP `doxcode`," . "\t\tDROP `doimage`," . "\t\tDROP `dobr`";
        $GLOBALS['xoopsDB']->queryF($sql);
    } else {
        xoops_error($GLOBALS['xoopsDB']->error() . "<br />" . $sql);
    }
    @(include_once XOOPS_ROOT_PATH . "/modules/tag/include/functions.php");
    if (function_exists("tag_getTagHandler") && ($tag_handler =& tag_getTagHandler())) {
        $table_topic = $GLOBALS['xoopsDB']->prefix("bb_topics");
        $sql = "\tSELECT topic_id, topic_tags" . "\tFROM {$table_topic}";
        if (($result = $GLOBALS['xoopsDB']->query($sql)) == false) {
            xoops_error($GLOBALS['xoopsDB']->error());
        }
        while ($myrow = $GLOBALS['xoopsDB']->fetchArray($result)) {
            if (empty($myrow["topic_tags"])) {
                continue;
            }
            $tag_handler->updateByItem($myrow["topic_tags"], $myrow["topic_id"], $module->getVar("mid"));
        }
    }
    if (!$GLOBALS['xoopsDB']->query("\r\n\t\t\tSELECT COUNT(*)\t\r\n\t\t\tFROM " . $GLOBALS['xoopsDB']->prefix("bb_type_tmp") . " AS a, " . $GLOBALS['xoopsDB']->prefix("bb_type_forum_tmp") . " AS b\r\n\t\t\tWHERE a.type_id = b.type_id AND a.type_id >0;\r\n\t\t")) {
        xoops_error($GLOBALS['xoopsDB']->error());
        $GLOBALS['xoopsDB']->queryF("DROP TABLE " . $GLOBALS['xoopsDB']->prefix("bb_type_tmp"));
        $GLOBALS['xoopsDB']->queryF("DROP TABLE " . $GLOBALS['xoopsDB']->prefix("bb_type_forum_tmp"));
        return true;
    }
    $GLOBALS['xoopsDB']->queryF("\tINSERT INTO " . $GLOBALS['xoopsDB']->prefix("bb_type") . "\t\t(`type_id`, `type_name`, `type_color`)" . "\tSELECT `type_id`, `type_name`, `type_color`" . " \t\tFROM " . $GLOBALS['xoopsDB']->prefix("bb_type_tmp"));
    $GLOBALS['xoopsDB']->queryF("\tINSERT INTO " . $GLOBALS['xoopsDB']->prefix("bb_type_forum") . "\t\t(`type_id`, `forum_id`, `type_order`)" . "\tSELECT `type_id`, `forum_id`, `type_order`" . " \t\tFROM " . $GLOBALS['xoopsDB']->prefix("bb_type_forum_tmp"));
    $GLOBALS['xoopsDB']->queryF("DROP TABLE " . $GLOBALS['xoopsDB']->prefix("bb_type_tmp"));
    $GLOBALS['xoopsDB']->queryF("DROP TABLE " . $GLOBALS['xoopsDB']->prefix("bb_type_forum_tmp"));
    return true;
}
Пример #4
0
 /**
  * Delete keyword-article links of the article from database
  * 
  * @param    object    $article     {@link Article} reference to Article
  * @return     bool     true on success
  */
 function deleteKeywords(&$article)
 {
     if (!@(include_once XOOPS_ROOT_PATH . "/modules/tag/include/functions.php")) {
         return false;
     }
     if (!($tag_handler =& tag_getTagHandler())) {
         return false;
     }
     $tag_handler->updateByItem(array(), $article->getVar("id"), "ilog");
     return true;
 }