t=t+"<A HREF=\"%s\" onClick=\"return confirm('Are you sure you want to quit this submission?')\">\n" % mainmenu
t=t+"<IMG SRC=\"%s/mainmenu.gif\" border=0 ALT=\"back to main menu\" align=right></A><BR><BR>\n" % images
t=t+"""
<HR>
<small>(1) you should take note of this number at the beginning of the submission, it will allow you to get your information back in case your browser crashes before the end of the submission.</small><BR>"""
# Add the summary window definition if needed
t=t+" <small>(2) mandatory fields appear in red in the 'Summary' window.</small><BR>\n"
global rn,sysno,dismode,curdir,uid,uid_email,lats_step,action_score
try:
rn
except NameError:
rn = ""
dismode = mode
ln = wash_language(ln)
sys.stdout = req
t=""
# get user ID:
try:
uid = getUid(req)
uid_email = get_email(uid)
except MySQLdb.Error, e:
return errorMsg(e.value)
# Preliminary tasks
# check that the user is logged in
if uid_email == "" or uid_email == "guest":
return warningMsg("<center><font color=red>Sorry, you must log in to perform this action. Please use the top right menu to do so.</font></center>",req,cdsname,ln)
# If we are in the last step of an action, we can update the "journal of submissions"
if last_step == 1:
if uid_email != "" and uid_email != "guest" and rn != "":
res = run_sql("SELECT * FROM sbmSUBMISSIONS WHERE doctype=%s and action=%s and id=%s and email=%s", (doctype,act,access,uid_email,))
if len(res) == 0:
run_sql("INSERT INTO sbmSUBMISSIONS values(%s,%s,%s,'finished',%s,%s,NOW(),NOW())", (uid_email,doctype,act,access,rn,))
else:
run_sql("UPDATE sbmSUBMISSIONS SET md=NOW(),reference=%s,status='finished' WHERE doctype=%s and action=%s and id=%s and email=%s", (rn,doctype,act,access,uid_email,))
t=t+""" <BR><BR>
</TD>
</TR>
<TR class=submitHeader>
<TD class=submitHeader colspan=5 align=center>"""
if finished == 0:
t=t+"<small>Submission no</small>²:\n"
t=t+"<small>%s</small>\n" % access
else:
t=t+" \n"
t=t+"""
</TD>
</TR>
</TABLE>
</center>
</form>
<br>
<br>"""
# Add the "back to main menu" button
if finished == 0:
t=t+ " <A HREF=\"%s\" onClick=\"return confirm('Are you sure you want to quit this submission?')\">\n" % mainmenu
else:
t=t+" <A HREF=\"%s\">\n" % mainmenu
t=t+"<IMG SRC=\"%s/mainmenu.gif\" border=0 ALT=\"back to main menu\" align=\"right\"></A><BR><BR>\n" % images
res2 = run_sql("SELECT * FROM sbmIMPLEMENT LEFT JOIN sbmACTION on sbmACTION.sactname=sbmIMPLEMENT.actname WHERE docname=%s and displayed='Y' ORDER BY sbmIMPLEMENT.buttonorder", (docShortDesc,))
for arr2 in res2:
res = run_sql("SELECT * FROM sbmACTION WHERE sactname=%s", (arr2[1],))
res = run_sql("SELECT * FROM sbmIMPLEMENT WHERE docname=%s and level!='0' and level=%s and score>%s ORDER BY score", (doctype,currentlevel,action_score,))
if len(res) > 0:
t=t+Request_Print("A","<BR><BR>You now have to<ul>")
first_score = res[0][10]
for i in range(0,len(res)):
action = res[i]
if action[10] == first_score:
if i > 0:
t=t+Request_Print("A"," <b>or</b>");
res2 = run_sql("SELECT dir FROM sbmACTION WHERE sactname=%s", (action[1],))
res = run_sql("SELECT * FROM sbmSUBMISSIONS WHERE doctype=%s and action=%s and id=%s and email=%s and status='finished'", (doctype,act,access,uid_email,))
if len(res) > 0:
return 1
else:
return 0
class functionError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
class functionStop(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
def errorMsg(title,req,c=cdsname,ln=cdslang):
return page(title="error",
body = create_error_box(req, title=title,verbose=0, ln=ln),
description="%s - Internal Error" % c,
keywords="%s, CDSware, Internal Error" % c,
language=ln,
urlargs=req.args)
def warningMsg(title,req,c=cdsname,ln=cdslang):
return page(title="warning",
body = title,
description="%s - Internal Error" % c,
keywords="%s, CDSware, Internal Error" % c,
language=ln,
urlargs=req.args)
def getCookie(name,uid):
# these are not real http cookies but are stored in the DB
res = run_sql("select value from sbmCOOKIES where uid=%s and name=%s", (uid,name,))
if len(res) > 0:
return res[0][0]
else:
return None
def setCookie(name,value,uid):
# these are not real http cookies but are stored in the DB
res = run_sql("select id from sbmCOOKIES where uid=%s and name=%s", (uid,name,))
if len(res) > 0:
run_sql("update sbmCOOKIES set value=%s where uid=%s and name=%s", (value,uid,name,))
else:
run_sql("insert into sbmCOOKIES(name,value,uid) values(%s,%s,%s)", (name,value,uid,))
return 1
def specialchars(text):
text = string.replace(text,"“","\042");
text = string.replace(text,"”","\042");
text = string.replace(text,"’","\047");
text = string.replace(text,"—","\055");
text = string.replace(text,"…","\056\056\056");