1 (defun authorize (proj)
2 (setvar 'uid (remote-user))
3 (sql "select a.UID,Login,Name,case when b.UID notNull then '1' else '' end from Member a left join Admin b where a.UID=:uid"
5 :answer '(UID Login Name Admin))
7 (sql "select PID,PublicProj from Project where Proj=:proj"
11 (sql "select PID,Proj,PublicProj from Project where Proj='Main'"
12 :answer '(PID Proj Public))
14 (if (not-emptyp Public)
19 (if (not-emptyp Public)
22 (sql "select Reader,Writer from ProjectMember where PID=:pid and UID=:uid"
23 :bind (list ':pid PID ':uid UID)
24 :answer '(Reader Writer))
28 (set-wikivar 'UID 'Login 'Name 'Admin 'PID 'Public 'Reader 'Writer)
31 (defun wiki-page (pid page)
33 (let (wid date title text)
34 (sql "select a.WID,a.Title,a.WikiText,b.Date from Wiki a,WikiIndex b using(WID) where b.PID=:pid and b.Page=:page"
35 :bind (list ':pid pid ':page page)
36 :answer '(wid title text date))
38 (regex "^-special-" page))
39 (sql "select a.WID,a.Title,a.WikiText,b.Date from Wiki a,WikiIndex b using(WID),Project c using(PID) where c.Proj='Main' and b.Page=:page"
40 :bind (list ':page page)
41 :answer '(wid title text date))
44 (if (and (emptyp wid) Edit)
46 'text (concat "=" page "=\n"))
48 (list date title text)
53 (defun wiki-save (page title text)
54 (let (iid wid date uid nwid)
56 (sql "select IID,WID,Date,UID from WikiIndex where PID=:pid and Page=:page"
57 :bind (list ':pid PID ':page Page)
58 :answer '(iid wid date uid))
59 (if (and (not-emptyp wid)
60 (> date (- (now) 10800))
62 (progn (sql "update Wiki set Title=:title,WikiText=:text where WID=:wid"
63 :bind (list ':title title ':text text ':wid wid))
64 (sql "update WikiIndex set IP=:ip,Date=:date where IID=:iid"
65 :bind (list ':ip (remote-ip) ':date (now) ':iid iid))
67 (sql "insert into Wiki(Title,WikiText) values(:title,:text)"
68 :bind (list ':title title ':text text))
69 (setvar 'nwid (rowid))
71 (sql "insert into WikiIndex(PID,Page,UID,IP,Date,WID) values(:pid,:page,:uid,:ip,:date,:wid)"
72 :bind (list ':pid PID ':page page ':uid UID ':ip (remote-ip) ':date (now) ':wid nwid))
73 (sql "insert into BackupIndex(PID,Page,UID,IP,Date,WID) select PID,Page,UID,IP,Date,WID from WikiIndex where IID=:iid"
75 (sql "update WikiIndex set UID=:uid,IP=:ip,Date=:date,WID=:wid where IID=:iid"
76 :bind (list ':uid UID ':ip (remote-ip) ':date (now) ':wid nwid ':iid iid))
83 (defun wiki-page-index (cat vpage vtitle)
87 (sql "select a.Page,b.Title from WikiIndex a,Wiki b using(WID) where a.PID=:pid and a.Page not like 'special-%' order by a.Page"
89 :@answer (list vpage vtitle))
92 (sql "select a.Page,b.Title from WikiIndex a,Wiki b using(WID) where a.PID=:pid and a.IID not in (select IID from WikiCategory where PID=:pid) and a.Page not like 'special-%' order by a.Page"
93 :bind (list ':pid PID)
94 :@answer (list vpage vtitle))
95 (sql "select a.Page,b.Title from CategoryList c,WikiCategory d using(CID),WikiIndex a using(IID),Wiki b using(WID) where a.PID=:pid and c.CName=:cat and a.Page not like 'special-%' order by a.Page"
96 :bind (list ':pid PID ':cat cat)
97 :@answer (list vpage vtitle))
103 (defun wiki-page-index-special (vpage vtitle)
105 (sql "select a.Page,b.Title from WikiIndex a,Wiki b using(WID) where a.PID=:pid and a.Page like 'special-%' order by a.Page"
107 :@answer (list vpage vtitle))
111 (defun wiki-category-index (vname)
113 (sql "select CName from CategoryList where PID=:pid order by CName"
115 :@answer (list vname))
119 (defun wiki-add-category (name)
120 (if (not-emptyp name)
122 (sql "insert into CategoryList(PID,CName) values(:pid,:cat)"
123 :bind (list ':pid PID ':cat name))