====== Bureaucracy Plugin ====== ---- plugin ---- description: Easily create HTML forms and collect the data via email or use it to create pages. author : Andreas Gohr email : andi@splitbrain.org type : syntax lastupdate : 2010-01-22 compatible : 2009-12-25+ depends : conflicts : form similar : form, contact, conform tags : form, email, poll, create downloadurl: http://github.com/splitbrain/dokuwiki-plugin-bureaucracy/zipball/master sourcerepo : http://github.com/splitbrain/dokuwiki-plugin-bureaucracy/ bugtracker : http://github.com/splitbrain/dokuwiki-plugin-bureaucracy/issues donationurl: http://donate.dokuwiki.org/Bureaucracy ---- The bureaucracy plugin allows you to create a HTML form right within DokuWiki. Input format validation is automatically handled by the plugin and requires no coding. User input can be emailed to a preconfigured address or used to create new pages using a template. ===== Download and Installation ===== Download and install the plugin using the [[plugin:plugin|Plugin Manager]] using the download link given above. Refer to [[:Plugins]] on how to install plugins manually. ==== Changes ==== {{rss>http://github.com/feeds/splitbrain/commits/dokuwiki-plugin-bureaucracy/master}} ==== Recommended additional Plugins ==== You might want to use the [[CAPTCHA]] plugin to avoid automated spam. The [[swiftmail]] plugin may help when your DokuWiki can't send mails. This plugin can be used to gather data for use with the [[data]] plugin. An additional plugin to look at is the [[pagemod]] plugin which uses the bureaucracy plugin to add data to an existing page (in addition to the current templating and mailing functionality) ==== Warning ==== Without the CAPTCHA, this plugin should only be used on closed wikis, because it could easily be abused as a spam gateway. ===== Usage ===== {{ :plugin:bureaucracy.png?nolink|A sample form with validation errors}} Let's start with an example:
Action mail me@example.com Thanks "Thanks for submitting your valuable data." Fieldset "A set of fields" Textbox "Employee Name" "=Your Name" number "Your Age" >13 <99 email "Your E-Mail Address" textbox "Occupation (optional)" ! password "Some password" fieldset "even more fields" select "Please select an option" "Peaches|Apples|Oranges" static "Some static text that could be an agreement" yesno "Read the agreement?" textarea "Tell me about your self" textbox "You need to write 'agree' here" /^agree$/ submit
As you can see, you can define a email address where the data should be sent to and a thank you text to be shown when a user submitted the form. What follows are the various fields to fill in. Fields are defined by giving a type and a label. For ''fieldset''s and the ''submit'' button, the label is optional. Some fields like the ''select'' type need a third parameter. Additional constraints can be added after the main options. The plugin takes care of validating the form the field types and set constraints. Arguments need to be wrapped in double quotes when they contain spaces. ==== Fields ==== * action * The first parameter needs to be a supported action (see below). Currently supported are ''mail'', ''template'' and ''[[plugin:pagemod|pagemod]]'' (if this plugin is installed). * Additional parameters for type ''mail'': * one or more email addresses to send the data to (required) * Additional parameters for type ''template'': * name of a page or namespace (trailing colon) to use as template (required) * namespace where new pages shall be created (optional) * separator to use when combining multiple fields into the pagename (optional) * thanks * define a text to be displayed when the from was submitted. (optional) * fieldset * creates a new set of fields * a label is optional * may depend on the value of another field * static * adds some static text to the form * textbox * creates a single line input field * needs a label * password * creates a single line password input field * needs a label * email * creates a single line input field * needs a label * the input is validated to be a valid email address * number * creates a single line input field * needs a label * the input is validated to be numeric * textarea * creates a multi-line input field * needs a label * to change the default size (10 rows) to //N// rows, use the argument "x//N//" (optional) * yesno * creates a checkbox * needs a label * select * creates a dropdown list * needs a label * needs a second argument containing the select options separated by a pipe (|) char * hidden * creates an invisible field with static data * needs a second parameter with the value to use * submit * creates a submit button (required) * a button label is optional * user / users * a DokuWiki user or list of DokuWiki users * needs a label * provides autocompletion when using a current [[devel:develonly]] version of DokuWiki * date * a date in the format YYYY-MM-DD * needs a label * provides a date picker when using a current [[devel:develonly]] version of DokuWiki * ''addpage page_tpl page_tgt'' * adds another page ''page_tgt'' based on a template page ''page_tpl'' * only for use with the template action ==== Constraints and Defaults ==== * Start with a ''>'' followed by a number to require numeric data bigger than the given number * Start with a ''<'' followed by a number to require numeric data smaller than the given number * Start with a ''='' to set a default value * Put a single ''!'' char to make a field optional * Put a single ''@'' char to make its value be used for the pagename in template mode * Enclose a regular expression with ''/'' chars to require the the regexp to match before the field is accepted (case insensitive) ===== Action Modes ===== The bureaucracy does three things: - it displays a neat form - it validates user input - it gives the user input to a action mode The last step is where the data is processed. What action is to be used is defined in the ''action'' field as described above. Currently two modes are supported: ''mail'' and ''template''. Additional modes (e.g. for storing the data in a database) can easily be added. ==== mail mode ==== This is a simple action. When used all user input will be sent by email to the configured email address. See the example above how to use it. You may specify multiple mail addresses separated by spaces. ==== template mode ==== This action uses given pages as template, will replace defined placeholders with the user input and create wiki pages. When using this mode you need to make sure to mark at least one of the input fields to be used as pagename using the ''@'' character. The templates need to contain the same fields as your form, surrounded by ''@@'' characters. Let's have an example -- assume the following to be your form definition:
action template userstpl users : fieldset "Create Your User Page" select "What's your Continent?" "Europe|North America|South America|Asia|Australia" @ textbox "What's your Name?" @ textarea "Enter a short bio" submit
To create a new page the above will look for the page ''userstpl'' (given as second parameter in the action field). This page needs to contain placeholders to be replaced with the user data. Here is an example how this could look like: ====== @@What's your Name?@@ ====== I'm living in @@What's your Continent?@@. @@Enter a short bio@@ The above example form will use the use the continent and name to create a new page. The third parameter of the action field is a namespace that is prepended to the pagename. Because the fourth parameter of the action field is set to '':'' it will use the continent as a namespace, too. For example if I would fill the form, the resulting page would be ''users:europe:andreas_gohr''. When the third parameter is not given, the fields are joined with the character from the [[config:sepchar]] config option. E.g. it would result in ''users:europe_andreas_gohr''. The result then would look somewhat like this with all the user data filled in: ====== Andreas Gohr ====== I'm living in Europe. It's me :-) Alternatively you can just give an underscore (''_'') as template name and the plugin will attempt to use the configured [[:namespace template]]. You may also use ''##'' characters instead of the ''@@'' characters in placeholders. This makes it simpler to use this plugin with the [[data]] plugin. === ACL Checking & runas Option === By default this plugin will check for [[:ACLs]] in template mode using the permissions of the user filling the form. This means the user needs to have at least ''read'' permissions for the template and ''create'' permissions for the namespace where the new page should be saved. However sometimes you may want to give anonymous users a way to create pages in a restricted namespace without giving them any direct access. This is where the ''runas'' option comes into play. With this option you can specify a username in the [[config|config manager]]. The user you specify here will always be used for checking the permissions mentioned above, regardless of the user filling the form. This way you can specify the needed access for this particular virtual user in the [[acl|ACL manager]]. Note: the ''runas'' user does not need to exist. In fact it is recommended to use a non existing user. Even when it exists, permission checks are done on user level only, groups of the user will be ignored. ===== Feedback ===== ^ Use issue tracker linked at the top to provide bug reports and feature requests ^ ==== Dual actions ==== This is an ugly hack, but I wanted to use pagemod AND then send and email. Save the following as pagemodandmail.php in the bureaucracy/actions folder: run($data, $thanks, $pagemodargs, $errors); $class = 'syntax_plugin_bureaucracy_action_mail'; $emailer = new $class(); $emailsuccess = $emailer->run($data, $thanks, $emailargs, $errors); $rmsg = ''; if (!$pagemodsuccess) {$rmsg .= "Pagemod failed";} if (!$emailsuccess) {$rmsg .= "Emailing failed";} if ($rmsg=='') {return $thanks;} else {return $rmsg.join(',',$errors);} } } Then modify the ''action'' command to the following: ... action pagemodandmail :page:to:modify pagemodmacro email1@adress.here email2@address.here ... Hope this is useful :) ==== Feature request ==== I'd love to see: - an instruction to set the subject of the email (something like //Subject "This is the subject for this email"//), with a fallback to current behavior if no Subject is specified. - The ability to specify a wiki page using the "Thanks" attribute, resulting in a re-direct to that page on success (//Thanks [[:start]]//) - The ability to fill field defaults based on the user's DokuWiki profile (name, username, email address) using macros like those in the [[http://www.dokuwiki.org/plugin:newpagetemplate#substitutions|newpagetemplate]] plugin (//email "Email Address" "=@EMAIL@"//) 2008-12-03 [[m.mccarn@aicr.org]] I've done that: It might be a bit dirty how I've done it, but it works and it is expandable. The only odd thing is it works only in email and in textbox. cd/var/www/roehrs-ag/lib/plugins/bureaucracy vi syntax.php / case 'email' case 'email': global $INFO; $value = str_replace('@USER@',$_SERVER['REMOTE_USER'],$value); $value = str_replace('@NAME@',$INFO['userinfo']['name'],$value); $value = str_replace('@MAIL@',$INFO['userinfo']['mail'],$value); :wq 2009-02-17 muetze ---- > - The ability to specify a wiki page using the "Thanks" attribute, resulting in a re-direct to that page on success (//Thanks [[:start]]//) This should be possible when you change line 173 $R->doc .= '

'.hsc($data['thanks']).'

'; to the following $R->doc .= p_render('xhtml',p_get_instructions($data['thanks']),$info); Now it is possible to use wiki-syntax in the "Thanks" attribute. So you can use the include plugin to include a page into the result view. 2008-12-09 [[christian.moll@tudor.lu]] ---- Thanks for your efforts, but there are one issue I am not happy with. We get a lot of emails produced with bureaucracy, and it would be very helpful to have the email address of the sender directly in the subject. To easily sort the incoming mails. 2009-01-07 [[christian.moll@tudor.lu]] ---- I like this plug-in but for the way I would like to use it, I have a problem. I would like to make a few parts with a form and in between some other wiki information (movies with flowplay). And sent all the parts at the end in one e-mail. At the moment is it not possible to do this, because when the information is in the form block it is ignored and when I close the form block and open it after the information the plug-in malfunctions. 2009-01-16 Xavier Vrijdag **UPDATE** 01/02/2009 in order to parse wiki code within the form the following code has to be altered in the syntax.php at case 'static': (line 339)(delete the contents of the case "static") $hRender = new Doku_Renderer_xhtml(); $form->addElement('

'.$hRender->render($opt['label']).'

'); break;
With the new version add this code in fields/static.php function render($params, $form) { $this->_handlePreload(); if(!$form->_infieldset){ $form->startFieldset(''); } if ($this->error) { $params['class'] = 'bureaucracy_error'; } $hRender = new Doku_Renderer_xhtml(); $form->addElement('

'.$hRender->render($this->getParam('label')).'

'); }
---- **UPDATE** 27/01/2009 I improved the patch. the thanks section is now cut out of the match per regex. Hi, I created a patch that allows wiki syntax in the Thanks section and also multiline thanks lines. You have to patch the syntay.php file with this: 81c81 < --- > 87c87 < $lines = explode("\n",$match); --- > 90c90,106 < --- > // ------------------------- > // find the thanks part > $t = preg_split("/thanks/i",$match, -1); > if (isset($t) && count($t) > 1) { > // the thanks text and the rest is in [2] > $t1 = explode("\"",$t[1], 3); > > // replace single quotes with double quotes > $thanks = str_replace("'", "\"", $t1[1]); > // ------------------------------------------- > // assemble the match without the thanks section > $choppedmatch = $t[0].$t1[2]; > $lines = explode("\n",$choppedmatch); > > } else > $lines = explode("\n",$match); > // ------------------------------------------- 116,121d131 < // is thank you text? < if($args[0] == 'thanks'){ < $thanks = $args[1]; < continue; < } < 166,167d175 < }else{ < $thanks = hsc($thanks); 199,202c207,212 < $R->doc .= '
'; < $R->doc .= $success; < $R->doc .= '
'; < return true; --- > $R->doc .= '

'; > $hRender = new Doku_Renderer_xhtml(); > $R->doc .= $hRender->render($thanks); > $R->doc .= p_render('xhtml',p_get_instructions($success),$info); > $R->doc .= '

'; > return true;
and the template.php in the action folder with this: 93c93 < return $thanks.' '.html_wikilink($pagename); --- > return html_wikilink($pagename); Maybe this is can be included in the plugin!? Greetings martin --- //[[info@martinheinemann.net|Martin Heinemann]] 2009/01/27 17:07// Like the plug-in but I wanted to use the regexp feature to check correct date formatting. With UK dates we use "/" as the separator, but I can't use that in the regexp match because it needs to be enclosed in "/" chars. Or if you can't fix that can you provide a date field type, but make sure you can use date formats for different countries. --- //Anthony Yates 31/01/2009 10:00// > Anthony, you didn't leave an email address, but maybe you read this anyway: You can escape the "/" by using "\/" - that way there shouldn't be a problem with checking the date format you want. \\ --- //[[marg@rz.tu-clausthal.de|Christian Marg]] 2009/08/07 14:06// ---- I was using the Formular plugin, but it seems to be broken. This plugin works well instead! But there were two things missing that I needed: to be able to pass the form info to another script for processing, and to be able to grab GET values and put them into a hidden field. BTW, this is my first time ever doing DokuWiki programming, so please excuse me if this is not where I should be posting this. PASSING DATA: Sure, you could make an action every time you wanted to do this, but then you're modifying files in the plugin... so I made a new ACTION. */ class syntax_plugin_bureaucracy_action_shoot extends syntax_plugin_bureaucracy_actions { function run($data, $thanks, $argv, &$errors) { // make an array with input names all lowercase, // with no spaces and special chars removed $inputs = array(); foreach($data as $opt) { switch ($opt['cmd']) { case 'submit': break; case 'hidden': $label = $opt['label']; $inputs[$label] = $_POST[$label]; break; /*case 'fieldset': $value = strtolower(preg_replace("/[^a-zA-Z0-9]/", "", $opt['label']) ); $inputs['formname'] = $value; break;*/ default: $label = strtolower( preg_replace("/[^a-zA-Z0-9]/", "", $opt['label']) ); $inputs[$label] = $_POST['bureaucracy'][$opt['idx']]; } } // check if exernal script is available $escript = array_shift($argv); $escriptFolder = ""; foreach($argv as $entry) { $escriptFolder .= array_shift($argv) . "/"; } $escriptPath = DOKU_INC.$escriptFolder.$escript . '.php'; if(!$escript or !@file_exists($escriptPath)) { msg(sprintf($this->getLang('e_noscript').$escriptPath, $escript),-1); return false; } require_once($escriptPath); $class = $escript; $script = new $class(); $success = $script->run($inputs); if($success) { return $thanks; } return false; } } This script should be placed in a file called "shoot.php" and placed in the actions folder of the bureaucracy plugin. This takes all the labels of the form and turns them into script friend names, so "First Name: " becomes "firstname". Basically lowercase, no symbols, no spaces. Then it looks for a script you've defined in the form markup, and calls its run() function. You do whatever you want from there. Example form code:
Action shoot signupvalidator customScripts Thanks "Thanks for the submission! Captured!" Fieldset "Contact Info" textbox "First Name: " textbox "Last Name: " textbox "Title: " textbox "Company: " textbox "Street Address: " textbox "City: " textbox "ZIP: " textbox "State: " textbox "Telephone: " textbox "Fax: " email "E-Mail: " submit
The syntax for the action line goes: Action shoot //scriptname// **scriptfolder**. The action is called shoot, so it'll always be that, then the filename of the script. In my example above, I have a folder called "customScripts" located in my dokuwiki folder... so from the root of the server it looks like this: /var/www/wiki/customScripts. Without modifying the plugin itself, you can only have one folder, in the root. By my action can take more arguments/folders, but the main plugin only allots 2 arguments for the Action keyword. GET VARIABLES: This requires a bit of editing of the main plugin files, and it's not functioning exactly. I call out to the creator of this plugin for help! I've got things working enough where it takes any get variable and sets it as the value of a hidden field in the form. The entry looks like this: hidden "get_value_name" and in the URL: ?get_value_name=43 or something like that. There's a problem though: sure, you can pass in a get value using the URL, but if there is a validation error (like someone didn't put in a valid e-mail address), then the URL gets reset. If there is no get value in the URL, the hidden field isn't rendered (and even if it were, it wouldn't have a value), and then your script will fail since it won't have that value. Here's the diff: --- /Users/drew/Downloads/bureaucracy/syntax.php 2009-02-16 12:59:44.000000000 -0600 +++ /Volumes/johnnytatlock.com/wiki/lib/plugins/bureaucracy/syntax.php 2009-02-26 14:45:36.000000000 -0600 @@ -31,9 +31,10 @@ 'textarea' => 2, 'action' => 2, 'thanks' => 2, + 'hidden' => 2 ); // types that are no fields - var $nofield = array('action','static','fieldset','submit','thanks'); + var $nofield = array('action','static','fieldset','submit','thanks', 'hidden'); /** * return some info @@ -276,7 +277,6 @@ $form = new Doku_Form('bureaucracy__plugin'); $form->addHidden('id',$ID); - $captcha = false; // to make sure we add it only once foreach($data as $opt){ @@ -345,6 +345,9 @@ $form->addElement(''); break; + case 'hidden': + $form->addHidden(hsc($opt['label']), $_GET[hsc($opt['label'])]); + break; } } I also added a line in the en/lang.php for when a script wasn't found at the specified location : $lang['e_noscript'] = 'No script was found at that location: '; Please help! --- //Andrew Petersen 26/02/2009 15:20// ---- Thanks for this nice plugin. It would be great if the the form sender could have their email address included as the reply-to address on the outbound email. I am looking to have ICT service requests come from a bureaucracy form direct to a ticketing system. In this situation, we want the user's email address to replace the global 'mailto' value. I'll have a poke about in the code, but I'm not sure my coding skills are up to it. --- //Nick Fahey 26/02/2009 15:20// ---- Hi, I wondered if it is possible to include an image upload option to include an image on a generated userpage. ~ Harriet Lowe, 11/03/2009, 15.39 ---- First I love the plugin. I have a question that someone may have an answer too. How do you create a template off of the form and also email it? It seems to be a one or the other option?? --- //John Fehr 12/03/2009 10:05// ---- 2009-03-19 : I thought someone posted a datepicker patch for this plugin in the mailing list some time ago... true/false? I cannot seem to find it now. thanks in advance! ---- 2009-03-23: Thank you for this plugin. It's very useful for me but I've had some problems when editing the code to add "Thanks Section/Wiki format". If I edit the form page after this modification, I would obtain a white page where you can not see the form again. Does somebody know to solve this problem? Again, thanks! ---- 2009-03023: Any way to have the plugin append to a wikipage rather than create a new one? Currently you get an error as it tries to overwrite **TRY [[pagemod|Pagemod]]** ---- 2009-03-23: To the person asking about "Thanks Section/Wiki format" modification: I'm not sure, but I believe the suggested changes were based on an older version of the plugin. When I tried implementing the modification, the plugin broke with similar results to yours.--- //Andrew Petersen 2009-03-23 21:08// ---- 2009-03-23: To the person asking about "Thanks Section/Wiki format" modification: I'm not sure, but I believe the suggested changes were based on an older version of the plugin. When I tried implementing the modification, the plugin broke with similar results to yours.--- //Andrew Petersen 2009-03-23 21:08// ---- 2009-04-15: A definite improvement would be to enable the wiki owner to set a "reply to" mail address in the form, as it is, a mail sent by the form, is sent with a "reply to address", of the server administrator mail account where the wiki is installed. This is actually really bad as people might accidentally reply to that address, and not to an address of the server administrators choice, or for that sake the wiki owners choice, these might not be the same entities / persons. Blankspaces ( i.e. something like in order to create spacing between fields would be nice Also checkboxes - without a forced yes no, i.e. an optional tick would be nice in order to enable one to create a more general form that has multiple usage options. I also agree with the first suggestion regarding an instruction to set the subject of the email (something like Subject “This is the subject for this email”) - Perfect for SPAM filtering Where is the donation button for this plugin, it would be a nice way to encourage further development. Just a few remarks from us and a BIG THANK YOU for a nice plugin that makes our work a little easier. Best regards - Einar Petersen, Project Manager, The Global Ability Initiative ---- I found a bug which will prevent the successful replacement of variables in the template: If you use "/" in your Variable name, it conflicts with the Regex-Separator. Here's a simple patch that should escape the "/" before the string is used as a regex.--- template.php.orig 2009-08-06 15:00:09.000000000 +0200 +++ template.php 2009-08-06 14:59:48.000000000 +0200 @@ -24,7 +24,7 @@ // run through fields and prepare replacements foreach($data as $opt) { $value = $_POST['bureaucracy'][$opt['idx']]; - $label = preg_quote($opt['label']); + $label = preg_quote($opt['label'],'/'); if(in_array($opt['cmd'],$this->nofield)) continue; // handle pagenames: if($opt['pagename']){ --- //[[marg@rz.tu-clausthal.de|Christian Marg]] 2009/08/06 15:02// ---- When using "select"-Fields, there is an empty option added unconditionally which doesn't make sense when a default value is given or the "select"ion isn't optional. Have a patch. --- bureaucracy/syntax.php 2009-08-01 00:06:36.000000000 +0200 +++ syntax.php 2009-08-07 15:46:47.000000000 +0200 @@ -337,7 +337,7 @@ $vals = explode('|',$opt['args'][0]); $vals = array_map('trim',$vals); $vals = array_filter($vals); - array_unshift($vals,' '); + if (!$value && $opt['optional']) array_unshift($vals,' '); $form->addElement(form_makeListboxField($name,$vals,$value,$opt['label'],'',$class)); break; case 'static': \\ --- //[[marg@rz.tu-clausthal.de|Christian Marg]] 2009/08/07 16:07// ---- **Error: Template could not be found**\\ I had a form in my //support// namespace which I wanted to use template //abc// also stored in //support// to create messages in namespace //messages//. Simply adding //abc// as the template name just resulted in an error saying that the template could not be found or was unreadable. Since the template existed and I was the wiki administrator, I searched the code for the solution to the problem. \\ **Solution: add the namespace tree before the template name**\\ Example
action template support:abc messages _ ... \\ Now this __great__ plugin works just fine. 2009-08-13 - John ---- **Error: All forms within one page have same id="bureaucracy__plugin"** I suppose you are aware of this and tried to fix in the version from 21-07-2009. I have installed the latest version and it still attributes the same id to all forms. [[http://westwalewicz.pl/dw/dodaj/zwiedzanie|tarlaf]] //2009-09-03// **Solution: See my fix for this below -- Chris Usher //2009-11-17// ** ---- Dollar signs are apparently not correctly escaped (or something) so in template mode $1,000 shows up as @@,000. -- 9 Sept 2009 George ---- **Patch for multiple forms in a page**. Note, this includes my method to enable hidden fields too: *** bureaucracy/syntax.php Sun Aug 16 12:58:11 2009 --- bureaucracy/new_syntax.php Tue Nov 17 15:29:39 2009 *************** *** 18,23 **** --- 18,24 ---- class syntax_plugin_bureaucracy extends DokuWiki_Syntax_Plugin { // allowed types and the number of arguments var $form_id = 0; + var $handle_form_id = 0; var $argcheck = array( 'textbox' => 2, 'email' => 2, *************** *** 29,34 **** --- 30,36 ---- 'onoff' => 2, 'yesno' => 2, 'static' => 2, + 'hidden' => 2, 'textarea' => 2, 'action' => 2, 'thanks' => 2, *************** *** 89,94 **** --- 91,97 ---- $action = array('type'=>'','argv'=>array()); $thanks = ''; + $this->handle_form_id++; $idx = 0; // parse the lines into an command/argument array $cmds = array(); *************** *** 168,174 **** $thanks = hsc($thanks); } ! return array('data'=>$cmds,'action'=>$action,'thanks'=>$thanks); } /** --- 171,177 ---- $thanks = hsc($thanks); } ! return array('data'=>$cmds,'action'=>$action,'thanks'=>$thanks,'formid'=>hsc($this->handle_form_id)); } /** *************** *** 181,188 **** $this->form_id++; $errors = array(); ! if(isset($_POST['bureaucracy']) && $_POST['bureaucracy_id'] == $this->form_id){ ! $errors = $this->_checkpost($data['data']); // check CAPTCHA $ok = true; $helper = null; --- 184,191 ---- $this->form_id++; $errors = array(); ! if(isset($_POST['bureaucracy']) && $_POST['bureaucracy_id'] == $data['formid'] && $_POST['bureaucracy_id'] == $this->form_id){ ! $errors = $this->_checkpost($data['formid'],$data['data']); // check CAPTCHA $ok = true; $helper = null; *************** *** 216,227 **** * Validate any posted data, display errors using the msg() function, * put a list of bad fields in the return array */ ! function _checkpost($data){ $errors = array(); foreach($data as $opt){ // required ! if(trim($_POST['bureaucracy'][$opt['idx']]) === ''){ if($opt['optional']) continue; if(in_array($opt['cmd'],$this->nofield)) continue; $errors[$opt['idx']] = 1; --- 219,230 ---- * Validate any posted data, display errors using the msg() function, * put a list of bad fields in the return array */ ! function _checkpost($formid,$data){ $errors = array(); foreach($data as $opt){ // required ! if(trim($_POST['bureaucracy'][$opt['idx']]) === '' && $_POST['bureaucracy_id'] == $formid){ if($opt['optional']) continue; if(in_array($opt['cmd'],$this->nofield)) continue; $errors[$opt['idx']] = 1; *************** *** 343,348 **** --- 346,354 ---- case 'static': $form->addElement('

'.hsc($opt['label']).'

'); break; + case 'hidden': + $form->addElement(''); + break; case 'textarea': $rows = ($opt['rows']) ? $opt['rows'] : 10; $form->addElement('
-- Chris Usher //2009-11-17// ---- **e-mail-address as sender, when logged in** Some users miss the option to set the sending e-mail-address to that of the registered user. With the following modifications you can add this feature: in mail.php: (replace $txt = sprintf($this->getLang('mailintro')."\n\n\n",strftime($conf['dformat'])); with the following code $txt = sprintf($this->getLang('mailintro')."\n\n\n",strftime($conf['dformat'])); //logged in users will appear with their full name and e-mail-adress in the received e-mail $txt .= ($_SERVER['REMOTE_USER'] ? ($this->getLang('sender').$INFO['userinfo']['name']."\n") : ''); $txt .= ($_SERVER['REMOTE_USER'] ? ($this->getLang('email').$INFO['userinfo']['mail']."\n\n\n") : ''); in mail.php: replace if(!mail_send($to, $sub, $txt, $conf['mailfrom'])) with the following lines; this will let the email address of a registered user appear; if there is no email address given the DokuWiki default will be used $from = ($_SERVER['REMOTE_USER']&&$INFO['userinfo']['mail']) ? $INFO['userinfo']['mail'] : $conf['mailfrom'] if(!mail_send($to, $sub, $txt, $from)) { in your language-file /lang/de/lang.php you add: $lang['sender'] = 'Absender: '; $lang['email'] = 'E-Mail-Adresse: '; -- deshi //2009-11-25// ---- **layout for sent data (CSV)** As non database user often wish to process the received data, efforts to enable the possibility to send the data as a comma-separated/tab-separated value would be very helpful. \\ Scenario: You receive 1000 E-Mails you have to process; just copy&paste it in e.g. excel an filter it for relevant data. \\ This way complex surveys could be set up. **Solution** Save the actions/mail.php file in the plugin directory as actions/mailcsv.php and edit it as follows: getLang('mailsubject'),$ID); $txt = sprintf($this->getLang('mailintro')."\n\n\n",strftime($conf['dformat'])); foreach($data as $opt){ $value = $opt->getParam('value'); $label = $opt->getParam('label'); switch($opt->getFieldType()){ case 'fieldset': break; default: $txt .= "$value,"; } } if(!mail_send($to, $sub, $txt, $conf['mailfrom'])) { throw new Exception($this->getLang('e_mail')); } return $thanks; } } ---- **Mail action feature: CC to user-specified email field** To use the CC feature, just add a field "emailcc" in your mailform like you would use the normal "email" field. Add an alias (emailcc) for the field_mail class, save this new file as fields/emailcc.php: Modify action_mail class, apply this patch for actions/mail.php: --- mail.php-orig 2010-02-06 16:05:43.287891102 +0100 +++ mail.php 2010-02-06 16:07:18.223655945 +0100 @@ -15,4 +15,5 @@ // get recipient address(es) $to = join(',',$argv); + $cc = array(); $sub = sprintf($this->getLang('mailsubject'),$ID); @@ -24,4 +25,8 @@ switch($opt->getFieldType()){ + case 'emailcc': + if (!empty($value)) + $cc[]= $value; // add to recipient addresses + break; case 'fieldset': $txt .= "\n====== ".hsc($label)." ======\n\n"; @@ -33,6 +38,8 @@ } } + + $cc = join(',',$cc); - if(!mail_send($to, $sub, $txt, $conf['mailfrom'])) { + if(!mail_send($to, $sub, $txt, $conf['mailfrom'], $cc)) { throw new Exception($this->getLang('e_mail')); } louwrens -- 2010-02-06 ---- Is it possible to use mail and template action simultaneously? Sachin --2010-03-10