编辑投票数

有时,我们需要从其他来源纳入总数,例如针对特定主题的“Facebook 点赞数”。

如果能够对当前的投票数进行编辑,那将非常理想。虽然这可能看起来有些可疑,但我期望系统能自动添加一条回复,说明是谁、在何时、对什么进行了操作(类似于手动关闭主题时出现的提示)。例如:

“Rob 将投票数设置为 352。”

作为管理员,我可以随后编辑这条自动回复,并插入原因,例如:“已纳入 Facebook 帖子的点赞数。”

我推测投票数据是存储在某个表中并与用户 ID 关联的。因此,或许可以像为 discobot 分配 -2 用户 ID 一样,将投票修改记录关联到另一个虚构的用户 ID 下?

3 个赞

I know this is a year old, but you can do this by editing the database directly.

From what I’ve found in my spelunking, the plugin keeps information about votes in 2 locations: the topic_custom_fields table contains the vote count for each topic, and the user_custom_fields table contains the actual record of each vote, tied to a user.

If you just edit the vote count in topic_custom_fields, the new vote count will display-- but the next time someone votes, the plugin will cross-check with the user_custom_fields records, realize the count is incorrect, and “fix” it back to before the edit.

So you have to also edit the user_custom_fields table so it agrees. Luckily, even though on the frontend you’re limited to 1 vote per topic per user, it looks like you can insert as many records as you want for 1 user into the database. So something like this:

UPDATE topic_custom_fields SET value = 3 WHERE name = 'vote_count' AND topic_id = <topic_id>;
 
INSERT INTO user_custom_fields VALUES ( DEFAULT,<user_id>,'votes',<topic_id>,<timestamp>,<timestamp>);
INSERT INTO user_custom_fields VALUES ( DEFAULT,<user_id>,'votes',<topic_id>,<timestamp>,<timestamp>);
INSERT INTO user_custom_fields VALUES ( DEFAULT,<user_id>,'votes',<topic_id>,<timestamp>,<timestamp>);

That way, assuming the vote_count was 0 at first, you’ve set it to 3 and given it 3 records to chew on when it goes to cross-check that number. Seems to work o-k for me, and you should be able to set the user_id to -2 or whatever you want.