Introduction
Starting with Version 4.1.5 Build #1910, the CometPublication plugin delivered with the PublishingServer provides a couple of methods, which allow better integration of the Publication Management Planner with priint:comet InDesign Desktop and Server Plugins.
The standard set of scripts and configurations created with new Comet projects has also been updated to support these new features.
This documentation shows, how to optimize existing Comet projects or implementing new functionality based on the CometPublicationCScriptAddOns plugin.
At least, the two script optimizations described in Optimize Document Open Events On Server and Optimize Document Save Events On Server should be taken into account. It's highly recommended updating the configuration of existing Comet projects like shown in these examples.
Requirements
Implementing publication scripts as described in this documentation requires
- priint:publishing server 4.1.5 Build >= #1910
- priint:comet ID plug-ins 4.1 / 4.1.5 >= R23333
Integrating CometPublicationCScriptAddOns
To integrate the cscript add-ons, you simply have to include the generated cscript stub into your script:
#include "[pubserver]/plugin/com.priint.pubserver.comet.bridge.publication.CometPublicationCScriptAddOns.c"The functions available with this include are listed below.
Method Overview
The CometPublicationCScriptAddOns plugin (contained in the CometPublication plugin library) defines the following methods including cscript integration:
CometPublicationCScriptAddOns.createMasterDocument(String masterDocumentName): String
creates a new master document with the given name. Result is the ID of the newly created master document.
cscript function:char * createMasterDocument(char * masterDocumentName);
CometPublicationCScriptAddOns.deleteDocument(String documentId): void
deletes (i.e.: mark as deleted) a document or master document.
cscript function:int deleteDocument(char * documentId);
CometPublicationCScriptAddOns.getMetadataOptions(): String
gets the options configured on this server for meta data generation.
cscript function:char * getMetadataOptions();
CometPublicationCScriptAddOns.getRendererFileType(): String
gets the default file type for renderer documents on this server, i.e. .indd or .w2ml.
cscript function:char * getRendererFileType();
CometPublicationCScriptAddOns.isPublicationDocument(String documentId): boolean
gets, whether the document denoted by documentId is a publication document or not.
cscript function:int isPublicationDocument(char * documentId);
CometPublicationCScriptAddOns.markDocumentCheckedOut(String documentId): void
mark a document as checked out. This allows e.g. to upload document and meta data for a newly created master document record.
cscript function:int markDocumentCheckedOut(char * documentId);
CometPublicationCScriptAddOns.markDocumentClosed(String documentId): void
mark a document as closed. This allows to release a document, without cleaning up the workspace copy or executing any of the document checkin routines.
cscript function:int markDocumentClosed(char * documentId);
Usage Examples
Create a new Master Document
Description
This script asks for a master document name, creates a new master document record and uploads the current front document to the Publication Planner.
If the server is configured for priint:pdf renderer, the document will first be exported as a w2ml file and then uploaded to the server.
This script is included in the standard set of panel scripts created with a new Comet project starting with version 4.1.5, Build #1910.
This means: if your project was created with this or a later version, there is no need to add this script manually to your project.
If not, you can copy, adapt & paste the following code to a new panel script (we recommend creating a "Publication" panel script in the "InDesign Desktop Panels" node in ISON).
Functional Description
Pre Conditions
- connected to PublishingServer
- front document is in saved state (i.e. not modified, implies: document has been saved locally)
- Server is configured for InDesignServer renderer: the InDesign document is copied to a temporary file. This file is opened, checked in, closed and deleted afterwards
- Server is configured for priint:pdf renderer: the InDesign document is exported as w2ml document to a temporary file. This file is opened, checked in, closed and deleted afterwards
- new master document record exists
- uploaded document data including metadata is associated to the new master document record
- Publication panel is refreshed. If currently master documents are shown, the newly created document is shown in the list
- temporary documents have been closed and deleted
#include "internal/panels.h" #include "[pubserver]/plugin/com.priint.pubserver.comet.bridge.publication.CometPublicationCScriptAddOns.c" int main() { char * documentPath = alloc(4096); char * documentId = 0; int result = -1; int test = 0; char * pathTmp = alloc(4096); char * nameTmp = alloc(4096); char * extender = alloc(4096); char * buffer = alloc(4096); char * s1 = alloc(4096); char * s2 = alloc(4096); int dialogResult = 0; XMLTree tree; for (;;) { if (document::get_modified(gDocument) != 0) { showmessage("DOCUMENT_IS_MODIFIED"); break; } test = document::path(documentPath, gDocument); if (test == 0) { showmessage("DOCUMENT_HAS_NO_PATH"); break; } document::name(buffer, gDocument); strcpy(s1, translate("INPUT_MASTERDOCUMENT_NAME")); strcpy(s2, translate("TITLE_MASTERDOCUMENT_NAME")); dialogResult = askstring(buffer, s1, s2, 0, 0, 0); if (dialogResult == 0) { break; } progress::start(translate("UPLOADING_MASTER_DOCUMENT"), 4); if (strlen(buffer) == 0) { document::name(buffer, gDocument); } documentId = createMasterDocument(buffer); if (!documentId || strlen(documentId) == 0) { showerror("NEW_DOCUMENT_ID_EMPTY"); break; } // the document - no matter if w2ml or indd format - must be saved in the // XCache folder, so it is assumed to be a publication document: progress::step(translate("PREPARING"), 1); strcat(pathTmp, "$CACHE/publication/"); strcat(pathTmp, soap::client(soap::connection(), buffer)); extender = getRendererFileType(); sprintf(nameTmp, "%s%s", documentId, extender); // W2ML export mode if (strstr(extender, ".w2ml") == extender) { strcat(pathTmp, "/"); strcat(pathTmp, nameTmp); // export to XCache ... tree = server::get_elements(gDocument, kScopeDocument, 0, "xmlversion:3.1;content:tagged,properties;"); document::set_modified(gDocument, 0); xmlquery::write(tree, pathTmp); xmlquery::close(tree, 1); } // InDesign upload mode else { // copy to XCache ... file::duplicate(documentPath, pathTmp, nameTmp); strcat(pathTmp, "/"); strcat(pathTmp, nameTmp); } // since there is no document data yet uploaded to the server, we cannot // regularly checkout the document. However, the server status must be // checked out, otherwise subsequent checkin calls will fail: markDocumentCheckedOut(documentId); progress::step(translate("UPLOADING"), 1); priint::checkin(documentId, pathTmp); document::close(gDocument, 0); progress::step(translate("CLEANING_UP"), 1); file::remove(pathTmp); result = 0; break; } progress::step(translate("REFRESHING"), 1); if (result == 0) { // server side processing takes some time. We want to make sure, // that the updated list is shown after refresh: system::sleep(1000); placeholder::reload_panel(kPanelPublications, 1); } progress::stop(); if (documentId) release(documentId); if (documentPath) release(documentPath); if (pathTmp) release(pathTmp); if (nameTmp) release(nameTmp); if (extender) release(extender); if (buffer) release(buffer); if (s1) release(s1); if (s2) release(s2); return result; }
Optimize Document Open Events on Server
Description
This script is executed, after a document has been opened. If run with InDesignServer, it checks, whether the document being opened is a publication document. If yes, the scripts configured for publication documents are executed (as configured in event script publication::after checkout).
This is the standard version of the document::after open event script created with a new Comet project starting with version 4.1.5, Build #1910.
In earlier versions, the publication::after checkout routines were executed for all documents, which could cause errors on server and client side. We therefore recommend updating the document::after open scripts in older projects as shown below.
Functional Description
Pre Conditions
- connected to Publishing Server
- a document has just been opened
- if run on InDesignServer and the document is a publication document, checkout routines as configured in publication::after checkout have been run.
- if run on InDesign Desktop or the document is not a publication document, nothing happens
#include "[pubserver]/plugin/com.priint.pubserver.comet.bridge.publication.CometPublicationCScriptAddOns.c" int main() { if (system::is_server()) { if (isPublicationDocument(gDocumentID)) { publication::aftercheckout(gDocumentID, gDocumentPath); } } return 0; }
New Version of document::open / publication::after checkout scripts
With PublishingServer 4.1.5.1 Build #2327, new versions of the document:open and publication::after checkout scripts have been established: these scripts handle the situation, when a document has just been checked out and closed without saving and then is reopened locally.
The former behaviour was:
- document parameters were not set for this document
- the display name for this document was not set correctly
Unfortunately, parts pf the functionality have to bee implemented twice, because depending on the situation, certain environment variables are or are not defined in the script context. For new Comet projects, the improved versions of the scripts is generated automatically, for old projects it's highly recommended updating the scripts as follows:
publication::after checkout
int main () { int result = 0; wtlog ("", "\n***************************************\n* Publication: store publication / documentId '%s' in document xml structure, local path: '%s'\n", gDocumentID, gDocumentPath); result = xml::set_document_attribute(gDocument, "documentId", gDocumentID); if (document::get_modified()) { // document has to be saved in this stage, otherwise the documentId // documentId and thus linkage to the publication record might get lost // if the document is closed. document::save(); } result = xml::set_document_attribute(gDocument, "publication", publication::get_rootpublication_id (gDocumentID)); result = publication::apply_parameters (gDocument, gDocumentID); result = document::set_display_name (gDocument, publication::get_label (gDocumentID)); return result; }
document::after open
#include "[pubserver]/plugin/com.priint.pubserver.comet.bridge.publication.CometPublicationCScriptAddOns.c" int main() { int result = 0; char * documentId = alloc(4096); if (system::is_server()) { strcpy(documentId, gDocumentID); } else { xml::get_document_attribute(gDocument, "documentId", documentId); } if (strlen(documentId) && isPublicationDocument(documentId)) { result = xml::set_document_attribute(gDocument, "publication", publication::get_rootpublication_id (documentId)); result = publication::apply_parameters (gDocument, documentId); result = document::set_display_name (gDocument, publication::get_label (documentId)); } release(documentId); return result; }
Optimize Document Save Events on Server
Description
This script is executed, after a document has been saved. If run with InDesignServer, it checks, whether the document being saved is a publication document. If yes, the scripts configured for publication documents are executed (as configured in event script publication::after save and publication::checkin).
This is the standard version of the document::after save event script created with a new Comet project starting with version 4.1.5, Build #1910.
In earlier versions, the publication::after save routines were executed for all documents, which could cause errors on server and client side and also caused unnecessary processing on client and server side (generating and uploading meta data etc.) . We therefore recommend updating the document::after save scripts in older projects as shown below.
Functional Description
Pre Conditions
- connected to Publishing Server
- a document has just been saved
- if run on InDesignServer and the document is a publication document, save and checkin routines as configured in publication::after save and publication::checkin have been run.
- if run on InDesign Desktop or the document is not a publication document, nothing happens
#include "[pubserver]/plugin/com.priint.pubserver.comet.bridge.publication.CometPublicationCScriptAddOns.c" int main() { if (system::is_server()) { if (isPublicationDocument(gDocumentID)) { publication::aftersave(gDocumentID, gDocumentPath); publication::checkin(gDocumentID, gDocumentPath); } } return 0; }
Create Metadata for a Document
Description
This script creates the meta data package as it's being generated upon checkin of a publication document and saves the files in a folder next to the current document.
The first version is quite complex, because in priint:comet Plug-In <= R23333, some functionality essential for meta data generation (namely ceating the items.xml) were not available as cscript functions.
Two shorter versions of this script for newer priint:comet Plug-Ins (4.1 resp. 4.1.5 > R23353) are listed below.
You can copy, adapt & paste this script to a panel script (we recommend creating a "Publication" panel script in the "InDesign Desktop Panels" node in ISON)
Functional Description
Pre Conditions
- connected to PublishingServer
- current document is saved (i.e. not in modified state, this implies: has been saved and has a local path)
- beside that, this script can be executed for arbitrary documents, not only publication documents.
- a folder named like the document plus extension .meta has been created next to the document
- XML files for spreads, groups, elements, placeholders, items and the document have been created
- previews for each spread have been created (only variant 2 of the script, see below)
#include "[pubserver]/plugin/com.priint.pubserver.comet.bridge.publication.CometPublicationCScriptAddOns.c" #include "internal/products.h" char * targetFilePath(char * result, char * parentFolder, char * fileName) { strcpy(result, parentFolder); strcat(result, "/"); strcat(result, fileName); return result; } char * product2itemXML(Product product, char * destination, int * size) { char * buffer = alloc(4096); char * stmp = alloc(4096); int itmp = 0; destination = str_append(destination, " <item>\n", size); itmp = product::get(product, kID); sprintf(buffer, " <ID>%d</ID>\n", itmp); destination = str_append(destination, buffer, size); itmp = product::get(product, kID2); sprintf(buffer, " <ID2>%d</ID2>\n", itmp); destination = str_append(destination, buffer, size); itmp = product::get(product, kID3); sprintf(buffer, " <ID3>%d</ID3>\n", itmp); destination = str_append(destination, buffer, size); strcpy(stmp, product::gets(product, kStringID)); sprintf(buffer, " <stringID>%s</stringID>\n", stmp); destination = str_append(destination, buffer, size); itmp = product::get(product, kPageitemid); sprintf(buffer, " <pageitemID>%d</pageitemID>\n", itmp); destination = str_append(destination, buffer, size); itmp = product::get(product, kProductDocPosition); sprintf(buffer, " <document-position>%d</document-position>\n", itmp); destination = str_append(destination, buffer, size); itmp = product::get(product, kClassid); sprintf(buffer, " <classID>%d</classID>\n", itmp); destination = str_append(destination, buffer, size); itmp = product::get(product, kElementid); sprintf(buffer, " <elementID>%d</elementID>\n", itmp); destination = str_append(destination, buffer, size); itmp = product::get(product, kPreRuleid); sprintf(buffer, " <preruleID>%d</preruleID>\n", itmp); destination = str_append(destination, buffer, size); strcpy(stmp, product::get(product, kPreRuleparams)); sprintf(buffer, " <preruleParams>%s</preruleParams>\n", stmp); destination = str_append(destination, buffer, size); itmp = product::get(product, kPostRuleid); sprintf(buffer, " <postruleID>%d</postruleID>\n", itmp); destination = str_append(destination, buffer, size); strcpy(stmp, product::get(product, kPostRuleparams)); sprintf(buffer, " <postruleParams>%s</postruleParams>\n", stmp); destination = str_append(destination, buffer, size); itmp = product::get(product, kProductType); if (itmp == 4) { sprintf(buffer, " <type>pagetemplate</type>\n"); } else { sprintf(buffer, " <type>product</type>\n"); } destination = str_append(destination, buffer, size); if (itmp == 1) { sprintf(buffer, " <status>inserted</status>\n"); } else if (itmp == 2) { sprintf(buffer, " <status>moved</status>\n"); } else if (itmp == 3) { sprintf(buffer, " <status>removed</status>\n"); } else { sprintf(buffer, " <status>normal</status>\n"); } destination = str_append(destination, buffer, size); itmp = product::get(product, kProductPageType); sprintf(buffer, " <pageType>%d</pageType>\n", itmp); destination = str_append(destination, buffer, size); destination = str_append(destination, " </item>\n", size); release(buffer); release(stmp); return destination; } int main() { char * documentPath = alloc(4096); int result = -1; int test = 0; char * targetFolder = alloc(4096); char * targetFile = alloc(4096); char * metadataOptions = alloc(4096); char * buffer = 0; char * s1 = alloc(4096); char * s2 = alloc(4096); int dialogResult = 0; ProductList products = 0; Product product = 0; int productCount = 0; int i = 0; int bufferSize = 4096; int itemsFile; XMLTree tree = 0; for (;;) { if (document::get_modified(gDocument) != 0) { showmessage("DOCUMENT_IS_MODIFIED"); break; } test = document::path(documentPath, gDocument); if (test == 0) { showmessage("DOCUMENT_HAS_NO_PATH"); break; } progress::start(translate("GENERATING_METADATA"), 7); buffer = getMetadataOptions(); strcpy(metadataOptions, buffer); strcpy(s1, translate("INPUT_METADATA_OPTIONS")); strcpy(s2, translate("TITLE_METADATA_OPTIONS")); dialogResult = askstring(metadataOptions, s1, s2, 0, 0, 0); if (dialogResult == 0) { break; } strcpy(targetFolder, documentPath); strcat(targetFolder, ".meta/"); targetFile = targetFilePath(targetFile, targetFolder, "spreads.xml"); progress::step(translate("GENERATING", targetFile), 1); tree = server::get_spreads(gDocument, kScopeDocument, 0, metadataOptions); xmlquery::write(tree, targetFile); xmlquery::close(tree); targetFile = targetFilePath(targetFile, targetFolder, "elements.xml"); progress::step(translate("GENERATING", targetFile), 1); tree = server::get_elements(gDocument, kScopeDocument, 0, metadataOptions); xmlquery::write(tree, targetFile); xmlquery::close(tree); targetFile = targetFilePath(targetFile, targetFolder, "groups.xml"); progress::step(translate("GENERATING", targetFile), 1); tree = server::get_cometgroups(gDocument, kScopeDocument, 0, metadataOptions); xmlquery::write(tree, targetFile); xmlquery::close(tree); targetFile = targetFilePath(targetFile, targetFolder, "placeholders.xml"); progress::step(translate("GENERATING", targetFile), 1); tree = server::get_placeholders(gDocument, kScopeDocument, 0, metadataOptions); xmlquery::write(tree, targetFile); xmlquery::close(tree); targetFile = targetFilePath(targetFile, targetFolder, "notes.xml"); progress::step(translate("GENERATING", targetFile), 1); tree = server::get_notes(gDocument, kScopeDocument, 0, metadataOptions); xmlquery::write(tree, targetFile); xmlquery::close(tree); // finally the w2ml file strcat(metadataOptions, ";xmlversion:3.1;content:tagged,properties;"); targetFile = targetFilePath(targetFile, targetFolder, "document.w2ml"); progress::step(translate("GENERATING", targetFile), 1); tree = server::get_elements(gDocument, kScopeDocument, 0, metadataOptions); xmlquery::write(tree, targetFile); xmlquery::close(tree); // unfortunately, there is no cscript function to directly export // the "items.xml" from document: targetFile = targetFilePath(targetFile, targetFolder, "items.xml"); progress::step(translate("GENERATING", targetFile), 1); products = productlist::get_established(gDocument); productCount = productlist::length(products); strcpy(s1, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"); strcat(s1, "<psc:items "); strcat(s1, "xmlns:psc=\"http://comet.werk-ii.com/psc_items\" "); strcat(s1, "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "); strcat(s1, "xsi:schemaLocation=\"http://comet.werk-ii.com/psc_items psc_items.xsd\">\n"); strcat(s1, "<!-- CAUTION! This item XML was generated by a cscript. -->\n"); strcat(s1, "<!-- The following elements therefore are missing: -->\n"); strcat(s1, "<!-- * groupID (ID of the CometGroup created for this item) -->\n"); strcat(s1, "<!-- * layout_layers (layout layers used while building) -->\n"); for (i = 0; i < productCount; ++i) { product = productlist::get(products, i); s1 = product2itemXML(product, s1, &bufferSize); } s1 = str_append(s1, "</items>", &bufferSize); itemsFile = file::open(targetFile, "w"); file::write(itemsFile, s1, 0); file::close(itemsFile); document::set_modified(gDocument, 0); result = 0; break; } progress::stop(); if (documentPath) release(documentPath); if (targetFolder) release(targetFolder); if (targetFile) release(targetFile); if (buffer) release(buffer); if (s1) release(s1); if (s2) release(s2); return result; }
With priint:comet Plug-Ins >= 4.1 R23353
#include "[pubserver]/plugin/com.priint.pubserver.comet.bridge.publication.CometPublicationCScriptAddOns.c" #include "internal/products.h" char * targetFilePath (char * result, char * parentFolder, char * fileName) { strcpy(result, parentFolder); strcat(result, "/"); strcat(result, fileName); return result; } int main() { char * documentPath = alloc(4096); int result = -1; int test = 0; char * targetFolder = alloc(4096); char * targetFile = alloc(4096); char * metadataOptions = alloc(4096); char * buffer = 0; char * s1 = alloc(4096); char * s2 = alloc(4096); int dialogResult = 0; XMLTree tree = 0; for (;;) { if (document::get_modified(gDocument) != 0) { showmessage ("DOCUMENT_IS_MODIFIED"); break; } test = document::path (documentPath, gDocument); if (test == 0) { showmessage ("DOCUMENT_HAS_NO_PATH"); break; } progress::start(translate ("GENERATING_METADATA"), 6); buffer = getMetadataOptions(); strcpy(metadataOptions, buffer); strcpy (s1, translate("INPUT_METADATA_OPTIONS")); strcpy (s2, translate("TITLE_METADATA_OPTIONS")); dialogResult = askstring (metadataOptions, s1, s2, 0, 0, 0); if (dialogResult == 0) { break; } strcpy(targetFolder, documentPath); strcat(targetFolder, ".meta/"); targetFile = targetFilePath(targetFile, targetFolder, "spreads.xml"); progress::step(translate("GENERATING", targetFile), 1); tree = server::get_spreads(gDocument, kScopeDocument, 0, metadataOptions); xmlquery::write (tree, targetFile); xmlquery::close (tree); targetFile = targetFilePath(targetFile, targetFolder, "elements.xml"); progress::step(translate("GENERATING", targetFile), 1); tree = server::get_elements(gDocument, kScopeDocument, 0, metadataOptions); xmlquery::write (tree, targetFile); xmlquery::close (tree); targetFile = targetFilePath(targetFile, targetFolder, "groups.xml"); progress::step(translate("GENERATING", targetFile), 1); tree = server::get_cometgroups(gDocument, kScopeDocument, 0, metadataOptions); xmlquery::write (tree, targetFile); xmlquery::close (tree); targetFile = targetFilePath(targetFile, targetFolder, "placeholders.xml"); progress::step(translate("GENERATING", targetFile), 1); tree = server::get_placeholders(gDocument, kScopeDocument, 0, metadataOptions); xmlquery::write (tree, targetFile); xmlquery::close (tree); targetFile = targetFilePath(targetFile, targetFolder, "notes.xml"); progress::step(translate("GENERATING", targetFile), 1); tree = server::get_notes (gDocument, kScopeDocument, 0, metadataOptions); xmlquery::write (tree, targetFile); xmlquery::close (tree); targetFile = targetFilePath(targetFile, targetFolder, "items.xml"); progress::step(translate("GENERATING", targetFile), 1); tree = server::get_items (gDocument, kScopeDocument, 0, metadataOptions); xmlquery::write (tree, targetFile); xmlquery::close (tree); // finally the w2ml file strcat(metadataOptions, ";xmlversion:3.1;content:tagged,properties;"); targetFile = targetFilePath(targetFile, targetFolder, "document.w2ml"); progress::step(translate("GENERATING", targetFile), 1); tree = server::get_elements (gDocument, kScopeDocument, 0, metadataOptions); xmlquery::write (tree, targetFile); xmlquery::close (tree); document::set_modified(gDocument, 0); result = 0; break; } progress::stop(); if (documentPath) release(documentPath); if (targetFolder) release(targetFolder); if (targetFile) release(targetFile); if (buffer) release(buffer); if (s1) release(s1); if (s2) release(s2); return result; }
Using the all-in-one priint:create_metadata function
This script creates a zipped meta data folder, as it's being uploaded with the document upon checkin, intermediate files are deleted.
The script allows to override certain options for meta data generation with user settings.
#include "[pubserver]/plugin/com.priint.pubserver.comet.bridge.publication.CometPublicationCScriptAddOns.c" int main() { char * documentPath = alloc(4096); int result = -1; char * metadataOptions = alloc(4096); char * s1 = alloc(4096); char * s2 = alloc(4096); int dialogResult = 0; int test = 0; for (;;) { if (document::get_modified(gDocument) != 0) { showmessage ("DOCUMENT_IS_MODIFIED"); break; } test = document::path (documentPath, gDocument); if (test == 0) { showmessage ("DOCUMENT_HAS_NO_PATH"); break; } progress::start(translate ("GENERATING_METADATA"), 2); strcpy(metadataOptions, getMetadataOptions()); strcpy (s1, translate("INPUT_METADATA_OPTIONS")); strcpy (s2, translate("TITLE_METADATA_OPTIONS")); dialogResult = askstring (metadataOptions, s1, s2, 0, 0, 0); if (dialogResult == 0) { break; } progress::step(translate ("GENERATING_METADATA")); result = priint::create_metadata(gDocument, 0, metadataOptions); break; } progress::step(translate ("GENERATING_METADATA")); if (s1) release(s1); if (s2) release(s2); if (documentPath) release(documentPath); if (metadataOptions) release(metadataOptions); progress::stop(); return result; }
Delete a Document / Master Document from Publication Panel
Description
This script deletes a document or master document (i.e.: set the "deleted" flag to 1). Of course, you should consider carefully, if you want to expose this functionality via a panel script to all users.
Functional Description
Pre Conditions
- connected to Publishing Server
- one or several document or master document entries are selected in the publication panel
Post Condition
- selected entries are marked as deleted (provided, the user has permission to delete these documents)
- list is refreshed, deleted documents disappear from list
#include "internal/panels.h" #include "[pubserver]/plugin/com.priint.pubserver.comet.bridge.publication.CometPublicationCScriptAddOns.c" int main() { IDTypeList selectedEntries = idtypelist::alloc(kPanelPublications, kSelected); int index; int size = idtypelist::length(selectedEntries); if (size == 0) { alert("OK", 0, 0, 1, 3, translate("PLEASE_SELECT_DOCUMENTS")); } progress::start(translate("PROCESSING"), size); for (index = 0; index < size; ++index) { IDType entry = idtypelist::get(selectedEntries, index); if (idtype::id(entry) != 2) { alert("OK", 0, 0, 2, 4, translate("CAN_ONLY_DELETE_DOCUMENTS", idtype::stringid(entry))); } else { int doit = alert("OK", "Cancel", 0, 2, 4, translate("DOCUMENT_REALLY_DELETE", idtype::stringid(entry))); progress::step(translate("DELETING"), 1); if (doit == 1) { deleteDocument(idtype::stringid(entry)); } } } progress::step(translate("REFRESHING"), 1); placeholder::reload_panel(kPanelPublications, 1); progress::stop(); idtypelist::release(selectedEntries); return 0; }
Close a Document / Master Document from Publication Panel
Description
This script marks a document as closed. This is the same functionality like unlocking a document from the "Checked out documents" panel in the Publication Planner. Of course, you should consider carefully, if you want to expose this functionality via a panel script to all users.
Functional Description
Pre Conditions
- connected to Publishing Server
- one or several document or master document entries are selected in the publication panel
Post Condition
- selected entries are marked as closed
- list is refreshed, documents have closed / available status
#include "internal/panels.h" #include "[pubserver]/plugin/com.priint.pubserver.comet.bridge.publication.CometPublicationCScriptAddOns.c" int main() { IDTypeList selectedEntries = idtypelist::alloc(kPanelPublications, kSelected); int index; int size = idtypelist::length(selectedEntries); if (size == 0) { alert("OK", 0, 0, 1, 3, translate("PLEASE_SELECT_DOCUMENTS")); } progress::start(translate("PROCESSING"), size); for (index = 0; index < size; ++index) { IDType entry = idtypelist::get(selectedEntries, index); if (idtype::id(entry) != 2) { alert("OK", 0, 0, 2, 4, translate("CAN_ONLY_CLOSE_DOCUMENTS", idtype::stringid(entry))); } else { int doit = alert("OK", "Cancel", 0, 2, 4, translate("DOCUMENT_REALLY_CLOSE", idtype::stringid(entry))); progress::step(translate("CLOSING"), 1); if (doit == 1) { markDocumentClosed(idtype::stringid(entry)); } } } progress::step(translate("REFRESHING"), 1); placeholder::reload_panel(kPanelPublications, 1); progress::stop(); idtypelist::release(selectedEntries); return 0; }