|
|
OP
Triggered Scripts
Script Triggers in OP allow you to automatically run scripts based on user actions, such as printing a page. Enable the checkbox to allow scripting on the Settings page.
These are scripts that automatically trigger following certain
events. The scripting language is JScript. Triggers are fired either instead of
an event or after the event occurs:
PrintSubst - Can cancel the print job if the script
returns a “false”.
OnPrint - Calls on the processing print job.
OnNotifyUserExceededQuota - Calls when the quota is exceeded.
Sample JScript Code:
// Calls when processing print
job
// return:
true - allow print job, false - reject print
job
function PrintSubst(
UserName, //
String
PrinterName, //
String
PrintServer, //
String
ComputerName, //
String
Document, //
String
Paper, //
String
TotalPages, //
int
JobSize, //
int
IsColor, //
boolean
IsDuplex) //
boolean
{
if (UserName == "john3")
return false;
else
return
true;
}
// Calls on processing print job
// return: none
function
OnPrint(
UserName, //
String
PrinterName, //
String
PrintServer, //
String
ComputerName, //
String
Document, //
String
Paper, //
String
TotalPages, //
int
JobSize, //
int
IsColor, //
boolean
IsDuplex, //
boolean
Cost, //
float
IsAllow, //
boolean
Reason) //
String
{
var fso, tf;
fso = new
ActiveXObject("Scripting.FileSystemObject");
tf = fso.CreateTextFile("c:\\testfile.txt", true);
tf.WriteLine(UserName) ;
tf.Close();
fso = null;
}
// Calls when quota exceeded
// return: none
function
OnNotifyUserExceededQuota (
UserName, //
String
PrinterName, //
String
PrintServer, //
String
ComputerName, //
String
Document, //
String
Paper, // String
TotalPages, //
int
JobSize, //
int
IsColor, //
boolean
IsDuplex, //
boolean
Reason) //
String
{
var objMessage =
new
ActiveXObject("CDO.Message");
objMessage.Subject = "Notify User Exceeded Quota" ;
objMessage.From = "myemail@gmail.com";
objMessage.To = "tomail@gmail.com";
objMessage.TextBody = "This is some sample message text.";
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")
= 2;
// Name or IP of
Remote SMTP Server
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")
= "smtp.gmail.com";
// Server port
(typically 25)
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")
= 25;
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")
= 1;
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl")
= true;
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername")
= "MyUserName";
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword")
= "MyPassword";
objMessage.Configuration.Fields.Update;
objMessage.Send();
objMessage = null;
}
|