Ejemplo n.º 1
0
    def WritePosts(self, user, groupid):
        if (self.name != Config.BLESS_BOARD
                and (self.DontStat() or (not self.IsNormalBoard()))):
            return 0
        now = time.time()

        postlog = PostLog()
        postlog.board = self.name
        postlog.groupid = groupid
        postlog.date = now
        postlog.number = 1

        postlog_new = PostLogNew()
        postlog_new.board = self.name
        postlog_new.groupid = groupid
        postlog_new.date = now
        postlog_new.number = 1
        postlog_new.userid = user.name

        xpostfile = "%s/tmp/Xpost/%s" % (Config.BBS_ROOT, user.name)

        log = True
        try:
            with open(xpostfile, "rb") as fp:
                while (True):
                    pl_data = fp.read(PostLog.size)
                    if (len(pl_data) < PostLog.size):
                        break

                    pl = PostLog(pl_data)
                    if (pl.groupid == groupid and pl.board == self.name):
                        log = False
                        break
        except IOError:
            pass

        if (log):
            Util.AppendRecord(xpostfile, postlog.pack())
            Util.AppendRecord(Config.BBS_ROOT + "/.newpost", postlog.pack())
            Util.AppendRecord(Config.BBS_ROOT + "/.newpost_new",
                              postlog_new.pack())

        return 0
Ejemplo n.º 2
0
    def CancelPost(self, user, entry, owned, append):
        # TODO: delete mail

        # rename post file
        new_filename = entry.filename
        rep_char = 'J' if owned else 'D'
        if new_filename[1] == '/':
            new_filename = entry.filename[0] + rep_char + entry.filename[2:]
        else:
            new_filename = rep_char + entry.filename[1:]

        oldpath = self.GetBoardPath(entry.filename)
        newpath = self.GetBoardPath(new_filename)
        os.rename(oldpath, newpath)

        entry.filename = new_filename
        new_title = "%-32.32s - %s" % (entry.title, user.name)

        if not append:
            entry.title = new_title
            entry.UpdateDeleteTime()
            # TODO: flush back entry changes
        else:
            postfile = PostEntry.PostEntry()

            postfile.filename = new_filename
            postfile.owner = entry.owner
            postfile.id = entry.id
            postfile.groupid = entry.groupid
            postfile.reid = entry.reid
            postfile.attachment = entry.attachment
            postfile.title = new_title
            postfile.UpdateDeleteTime()

            new_dir = self.GetDirPath('junk' if owned else 'deleted')
            Util.AppendRecord(new_dir, postfile.pack())

        return True
Ejemplo n.º 3
0
 def add_entry(self, entry):
     return (Util.AppendRecord(self.path, entry.pack()) == 0)