Plone: Email contents in content rule action - plone

I have a Plone site configured with PloneFormGen. I'm using a save-data-to-content adapter to create a page for each submission, with a unique number for title/id. I have content rules set up so that various roles will be notified when a submitted form transitions along the workflow.
Is there any way to include the content of the submitted in these emails? I know PloneFormGen can send the content of the form in an initial email at submit time, but I need to send this same information later. I'm pretty good at figuring things out, but I'm no Plone expert so any help would be appreciated.
Additional info:
I'm using the uwosh.pfg.d2c adapter to perform the PFG -> Contenttype conversion, which works well. The content type is set to 'page' in the settings for the uwosh.pfg.d2c plugin. Content rules then will send emails to various groups or roles based on a state transition of the resulting content, which works in the normal way - when a transition occurs, the rule executes.
Effectively, what we have is pages that are being generated by the form when the user clicks submit. This is done through a plugin in PloneFormGen. This may provide some extra info: http://pythonhosted.org/uwosh.pfg.d2c/ - I'm not, admittedly, much of a developer.
Ideally, reviewers would get body-text of the created page when the form is submitted: this is done through a content rule that when a page is added to a folder, it sends the email. The page is added to the folder when the plugin in PloneFormGen creates the page.
When we have these pages, other users can come in and review and change the state of them - just as you can with any other page in Plone. PloneFormGen should have no further use once it's been converted to a page. Hope that helps.

The bad news is that this will require programming; the good news is that it won't take much. There are two reasonable approaches to solving the problem:
Have your content rule action run a script that handles the mailing itself. You can use the site's mailhost to send scripted mail; or,
In a Python package (no way to do this in a through-the-web script), provide a named adapter implementing plone.stringinterp.interfaces.IStringSubstitution for your context's text attribute. That will give you a $ substitution for the body. This would probably require less than 10 lines of total code.

You might want to have a look a collective.contentrules.mailtogroup, the newest version is capable to send the body-text as mail (use the '${text}'-variable), triggered on one of the convenient content-rules-events, in your case 'Object added'.
You can assign your roles to a group and use it for your case.

Related

How to make form like example

there is this site https://www.delinski.at/ and it has a nice form where you can pick some values from dropdowns like Date, Number of Persons etc., and then submit the form. It redirects and I see the values on the redirected page link as parameters (if I have changed the defaults).
I searched for and tried several Form Plugins which all do not seem to work - most recent one (Form Maker) lets me design the form as I want but at the end I realized when I click on Submit, the values are not transfered to the target page (confirmed by Form Maker Support as work as intended). It's confusing because actually that should be a basic funciontality of a HTML form, right?
So I want to know if there are plugins where I can get a similar look&feel like the example given above.
That site is a Static Site Generated framework not WordPress. That site would also be very expensive to build cause that is all coded, and very well:)
You are not actually seeing a form there at all that is just how PHP natively uses the URL to navigate via a button.
Almost all the form plug ins for WP use the database write now and do not pass the parameters of the entered form as a php _ POST with a redirect.
I kind of think what you really are looking for is a faceted search feature
One of the best that comes to my mind is https://facetwp.com/demo/cars/?_vehicle_type=truck
Notice the car icons those are actually search buttons:) Of course you will have to build a template to do that neat stuff on the SSG site you linked but...
here is a really informative write upon how it works to get started.

Drupal: How to Figure Out the token for a Specific Field?

I would like to know how to 'construct' tokens. I have read many examples, but somehow I don't understand them. I am new to Drupal and at the moment I am testing how it works. I'm trying to hide the title of a content type I've created and automatically replace it with the content of another field. As far as I know, I have installed and enabled all the relevant modules including CCK and Automatic Entity Label. The only thing I don't know is what token I should use to make it happen. The field I would like to use as the source for the title field is called event (or possibly field_event) and is of type text. I'm visually impaired and either I'm doing something wrong, or the token browser is not too screen reader friendly. Either way, I can't access the list of all tokens to select the token, so I have to enter it manually. If I'm not mistaken, the token should include '[node:body]', right? But is it like '[node:event:body]' or '[field:event:body]' or something else?
Many thanks!
One Idea might be the devel module https://drupal.org/project/devel . Install it, activate it and visit some page of the node type you want to use the token on, and click on the devel tab and then on the token tab. et voila. or you navigate directly to e.g. yoursite.com/node/29/devel/token .
Hope it helps.

Webscraping a tricky asp.net page

The overall goal is to perform a search on the following webpage http://www.cma-cgm.com/eBusiness/Tracking/Default.aspx with a container value of CMAU1173561. I have tried two approaches, the php extension cURL and python's mechanized. The php approached involves a performing a POST submit using the input fields found on the page (NOTE: These are really ugly on the asp.net page). The returned page does not contain any of the search results. The second approaches involves using python's mechanize module. In this approach I load the page, select the form, then change the text field ctl00$ContentPlaceBody$TextSearch to the container value. When I load the response again no search results.
I am at a really dead end. Any help would be appreciate because as it stands my next step is to become a asp.net expertm which i perfer not to.
The source of that page is pretty scary (giant viewstate, tables all over the place, inline CSS, styles that look like they were copied from Word).
Regardless...an ASP.Net form still passes the same raw data to the server as any other form (though it is abstracted to the developer).
It's very possible that you are missing the cookies which go along with the request. If the search page (or any piece of the site) uses session state, the ASP.Net session cookie must be included in the request. You will be able to tell it from its name (contains "asp.net" and "session").
I assume that you have used a tool like Firebug or Chrome to view the complete outgoing request when the page is submitted. From my quick test, it looks like the request may be performed with a GET, not a POST. I submitted a form, looked at the request, and pasted the URL into a new browser window.
Example: http://www.cma-cgm.com/eBusiness/Tracking/Default.aspx?ContNum=CMAU1173561&T=57201202648
This may be all you need to do.

SCORM - How to update Lesson status using internal menu/quick link to next SCO in SCORM?

I have developed a course in HTML and I have created the menu and linked to respective html page in imsmanifest.xml the issue is if user navigate to next lesson using internal link the status is not updating in LMS e.g. SCO.html has internal link to SCO2.html
Can you have all your content pages call a javascript function to update lesson_location? That way when the new HTML page loads it will update the location. That's probably the easiest way, though not the most elegant.
In SCORM, you should not be directly linking from one SCO to another SCO. The LMS is responsible for navigation between SCOs. This is because, in SCORM, a SCO should be reusable in other courses that may not contain the other SCO you are linking to.
If you are using SCORM 2004, you can use an adl.nav request to request that the user be navigated to a certain SCO. If you are using SCORM 1.2, then you should either combine all of your existing SCOs into one big SCO, or just let the LMS present the table of contents and handle the navigation.
To get the status to update, make sure that you are always calling LMSFinish/Terminate whenever the SCO unloads. It is good practice to include these called in the onunload and onbeforeunload events to ensure that they are always invoked.
Also, make sure that you are setting cmi.core.lesson_status/cmi.completion_status as soon as the user has achieved completion. Ideally you should not wait for the SCO to be unloading to make these calls.
(More basic information on how the SCORM Run-Time works)
Simply updating the lesson location value will not automatically save your current location. You then need to retrieve this value and explicitly redirect your user back to where they left of.

Abusing HTTP POST

Currently reading Bloch's Effective Java (2nd Edition) and he makes a point to state, in bold, that overusing POSTs in web applications is inherently bad. Unfortunately, he doesn't specify why.
This startled me, because when I do any web development, all I ever use are POSTs! I have always steered clear of GETs for security reasons and because it felt more professional (long, unsightly URLs always bother me for some reason).
Are there performance differentials between GET and POST? Can anyone elaborate on why overusing POSTs is bad, and why? My understanding - and preliminary searches - seem to all indicate that these two are handles very similarly by the web server. Thanks in advance!
You should use HTTP as it's supposed to be used.
GET should be used for idempotent, read queries (i.e. view an item, search for a product, etc.).
POST should be used for create, delete or update requests (i.e. delete an item, update a profile, etc.)
GET allows refreshing the page, bookmark it, send the URL to someone. POST doesn't allow that. A useful pattern is post/redirect/get (AKA redirect after post).
Note that, except for long search forms, GET URLs should be short. They should usually look like http://www.foo.com/app/product/view?productId=1245, or even http://www.foo.com/app/product/view/1245
You should almost always use GET when requesting content. Only use POST when you are either:
Transmitting sensitive information which should not appear in the URL bar, or
Changing the state on the server (adding/changing/deleting stuff, altough recently some web applications use POST to change, PUT to add and DELETE to delete.)
Here's the difference: If you want to give the link to the page to a friend, or save it somewhere, or even only add it to your bookmarks, you need the full URL of the page. Just like your address bar should say http://stackoverflow.com/questions/7810876/abusing-http-post at the moment. You can Ctrl-C that. You can save that. Enter that link again, you're back at this page.
Now when you use any action other than GET, there is simply no URL to copy. It's like your browser would say you are at http://stackoverflow.com/question. You can't copy that. You can't bookmark that. Besides, if you would try to reload this page, your browser would ask you whether you want to send the data again, which is rather confusing for the non-tech-savy users of your page. And annoying for the entire rest.
However, you should use POST/PUT when transferring data. URL's can only be so long. You can't transmit an entire blog post in an URL. Also, if you reload such a page, You'll almost certainly double-post, because the above described message does not appear.
GET and POST are very different. Choose the right one for the job.
If you are using POST for security reasons, I might drop a mention of other security factors here. You need to ensure that you send the data from a form submit in encrypted form even if you are using POST.
As for the difference between GET and POST, it is as simple as GET is used to send a GET request. So, you would want to get data from a page and act upon it and that is the end of everything.
POST on the other hand, is used to POST data to the application. I am talking about transactions here (complete create, update or delete operations).
If you have a sensitive application that takes, say and ID to delete a user. You would not want to use GET for it because in that case, a witty user may raise mayhem simply changing the ID at the end of the URL and deleting all random uses.
POST allows more data and can be hacked to send streams of files as well. GET has a limited size though.
There is hardly any tradeoff in using GET or POST.

Resources