<% lvl=validate(0) canid=request("canid") if canid="" or not(isnumeric(canid)) then canid=0 set conn=server.createobject("ADODB.Connection") conn.open connection psql="select * from xlaALScans where canid="&canid if lvl=0 then psql=psql & " and canscope=0" '/// Register Can if request("button")<>"" then canscope=0 canname=request("canname") cancmd=request("cancmd") canmsg=replace(request("canmsg")&"",chr(34),"'") general=request("general") users=replace(request("users")&""," ","") depts=replace(request("depts")&""," ","") if canname="" or cancmd="" or canmsg="" then errormsg="Please provide a name and command for the canned command.
" if lvl=1 and users="" and depts="" and general="" then errormsg=errormsg & "No scope was defined for the canned command." if errormsg="" then if instr(users,",")<>0 then canscope=1 if depts<>"" then canscope=1 if general<>"" then canscope=2 if lvl=0 then canscope=0 users=getusrid end if '/// Preapare Processed Can if cancmd<>0 then processedcan=preparemsg(canmsg) else processedcan=canmsg select case cancmd case 0 'Text Answer '//Nothing, Just pass the text case 1 'Push URL processedcan="cmdpush('"&processedcan&"','$$ALIAS$$')" case 2 'Image processedcan="cmdimage('"&processedcan&"','$$ALIAS$$')" case 3 'Hyperlink processedcan="cmdurl('"&processedcan&"','$$ALIAS$$')" case 4 'E-Mail processedcan="cmdemail('"&processedcan&"','$$ALIAS$$')" case 5 'Reference Link processedcan=canmsg end select Set rs = Server.CreateObject("ADODB.Recordset") rs.open psql,conn,1,2 if rs.eof then rs.addnew rs("canname")=canname rs("cancmd")=cancmd rs("canmsg")=canmsg rs("processedcan")=processedcan rs("canscope")=canscope rs.update canid=rs("canid") rs.close set rs=nothing '//// Save and users Depts if any /// psql="delete from xlaALSiDeptsCans where canid="&canid conn.execute(psql) psql="delete from xlaALSiUsersCans where canid="&canid conn.execute(psql) if canscope<>2 then thedepts=split(depts,",") theusers=split(users,",") '/// Depts for x=0 to ubound(thedepts) psql="insert into xlaALSiDeptsCans (canid,deptid) values ("&canid&","&thedepts(x)&")" conn.execute(psql) next '/// Users for x=0 to ubound(theusers) psql="insert into xlaALSiUsersCans (canid,userid) values ("&canid&","&theusers(x)&")" conn.execute(psql) next conn.close set conn=nothing end if response.redirect "cans.asp" end if elseif canid>0 then set rs=conn.execute(psql) if rs.eof then rs.close set rs=nothing conn.close set conn=nothing response.redirect "logout.asp" end if canname=rs("canname") cancmd=rs("cancmd") canmsg=rs("canmsg") canscope=rs("canscope") rs.close set rs=nothing if canscope<>2 then '/// not a general can psql="select deptid from xlaALSiDeptsCans where canid="&canid depts="," set rs=conn.execute(psql) do until rs.eof depts=depts&rs("deptid")&"," rs.movenext loop rs.close set rs=nothing psql="select userid from xlaALSiUsersCans where canid="&canid users="," set rs=conn.execute(psql) do until rs.eof users=users&rs("userid")&"," rs.movenext loop rs.close set rs=nothing else general="checked" end if end if %> <%=title%>
<%if errormsg<>"" then%> <%end if%> <%if lvl=1 then%> <%end if%>
Edit Canned Command <%if canid>0 then%> <%end if%>
Error : The canned command could not be saved
Name :
Type a name for this canned command
Command :

Select the Type of command and the URL or message that you want to use in the command
Scope :
Select Which representatives will have access to this command
> All The Representatives
Departments :
<% conn.close set conn=nothing %>