TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,911
  • Total Topics: 21,307
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 361
  • Total: 362
  • tino

Generic Application Form

Started by JPDeni, May 23, 2009, 11:04:28 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

EasyRider

So, i have to try again to add the correct code..  :)

And i come back to tell you what i thing for the format and tell my if it is possible.
SMF  1.1.11 / TinyPortal v1.0 beta 4 /default theme

EasyRider

Quote from: JPDeni on September 24, 2009, 04:28:01 PM
Which code did you enter? I gave you two sets of code earlier. The first only will bold the caption. The second adds the red. (I was showing you different options. :) )

It's possible to format it any way you want. Tell me exactly how you want it formatted and I'll post the code. :)


I enter the second code with red color in caption text area option. But not any red color print in post.  Only bold captions everywhere..
SMF  1.1.11 / TinyPortal v1.0 beta 4 /default theme

JPDeni

Odd. It works perfectly on my site.

I don't know what it could be ... unless ... is it possible that you do not allow the color tag in your forum? That's the only reason I can think of that it wouldn't show.

ed_m2

out of interest... is there any permission checking on the topic posting option ?

if i use this then the topic will be sent to a private board before being approved and moved to a public board.

so if the submitter does not have access to the private board will it still post the message ?

EasyRider

Hi JPDeni  :)  my original code is this:
(i do something  wrong..?  ???)

global $sourcedir, $ID_MEMBER, $context, $scripturl, $user_info, $db_prefix;

// Guests can't fill out the form
if ($ID_MEMBER == 0)
    echo 'You must be logged in before you can apply.';
else {

require_once($sourcedir . '/Subs.php');
require_once($sourcedir .'/Subs-Post.php');


// CONFIGURATION SECTION

$intro_form = "ΠρέÏâ,¬ÃŽÂµÃŽÂ¹ να είναι ÏÆ'υμÏâ,¬ÃŽÂ»ÃŽÂ·ÃÂÃâ€°ÃŽÂ¼ÃŽÂ­ÃŽÂ½ÃŽÂ± ÏÅ'λα τα Ïâ,¬ÃŽÂµÃŽÂ´ÃŽÂ¯ÃŽÂ± για να είναι έγκυρη η κριτική ÏÆ'ας.";
$thanks_text = "This is what will appear after the form is submitted. You can use html. Be careful with quotation marks.";

// Define your fields. All of these values need to be defined, even if they are empty.
// The fields will be displayed in the order in which they are listed in the array.
// $fielddef =
//   array(
//     array(
//       'caption' =>      "", // caption to be displayed on the form. Can include symbols and spaces.
//       'name' =>         "", // a unique name for the field. No symbols or spaces
//       'type' =>         "", // text, radio, select, checkbox, textarea, heading
//       'options' =>      "", // for radio and select fields. List in order you wish them to appear, separated by commas; for checkboxes, it's the value to be saved and displayed next to the box
//       'defaultvalue' => "", // the default value for the field. Can be a variable or text. Be sure to enclose text in quotation marks
//       'required' =>     0   // 0 or 1 -- use 1 if the field must be filled out. use 0 if it's optional; never set a checkbox to be required
//     ),
//   );

$topicOptions = array(
'id' => 0 ,
'board' => $board_id,
'poll' =>  null,
'lock_mode' =>  null,
'sticky_mode' =>  null,
'mark_as_read' => true,
);
$fielddef =
array(
array(
'caption' =>      "Πληροφορίες ΣυνάντηÏÆ'ης",
'name' =>         "heading",
'type' =>         "heading",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
),
array(
'caption' =>      "ÃŽâ€"μερομηνία ÏÆ'υνάντηÏÆ'ης",
'name' =>         "date",
'type' =>         "text",
'options' =>      "",
'defaultvalue' => "",
'required' =>     1
), 

                                  array(
'caption' =>      "ΣυμÏâ,¬ÃŽÂµÃÂÃŽÂ¹Ãâ€ ÃŽÂ¿ÃÂÃŽÂ¬ Ïâ,¬ÃÂÃŽÂ±ÃŽÂºÃâ€žÃŽÂ¿ÃÂÃŽÂµÃŽÂ¯ÃŽÂ¿Ãâ€¦",
'name' =>         "feedback1",
'type' =>         "select",
'options'=>                        "select,κακη,μετρια,καλη",
'defaultvalue' => "1",
'required' =>     1
),
                                  array(
'caption' =>      "Î¥Ïâ,¬ÃŽÂ·ÃÂÃŽÂµÃÆ'ίες ΚοÏâ,¬ÃŽÂ­ÃŽÂ»ÃŽÂ±Ãâ€š",
'name' =>         "heading",
'type' =>         "heading",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
),
                                  array(
'caption' =>      "ΕμφάνιÏÆ'η (Ïâ,¬ÃÂÃÅ'ÏÆ'ωÏâ,¬ÃŽÂ¿)",
'name' =>         "feedback5",
'type' =>         "select",
'options' =>      "select,3,4,5,6,7,8,9,10",
'defaultvalue' => "1",
'required' =>     1
),
                                  array(
'caption' =>      "ΕμφάνιÏÆ'η (ÏÆ'ώμα)",
'name' =>         "feedback5",
'type' =>         "select",
'options' =>      "select,3,4,5,6,7,8,9,10",
'defaultvalue' => "1",
'required' =>     1
),
   array(
'caption' =>      "Γενική ÏÆ'υμÏâ,¬ÃŽÂµÃÂÃŽÂ¹Ãâ€ ÃŽÂ¿ÃÂÃŽÂ¬",
'name' =>         "feedback6",
'type' =>         "select",
'options' =>      "select,3,4,5,6,7,8,9,10",
'defaultvalue' => "1",
'required' =>     1
),
array(
'caption' =>      "ΕÏâ,¬ÃŽÂ¹ÃŽÂºÃŽÂ¿ÃŽÂ¹ÃŽÂ½Ãâ€°ÃŽÂ½ÃŽÂ¯ÃŽÂ±",
'name' =>         "feedback7",
'type' =>         "select",
'options' =>      "select,3,4,5,6,7,8,9,10",
'defaultvalue' => "1",
'required' =>     1
),
array(
'caption' =>      "ΔιάθεÏÆ'η ÏÆ'το ÏÆ'εξ/ÏÆ'υμμετοχή",
'name' =>         "feedback8",
'type' =>         "select",
'options' =>      "select,3,4,5,6,7,8,9,10",
'defaultvalue' => "1",
'required' =>     1
),
                                  array(
'caption' =>      "Πεολειχία",
'name' =>         "feedback2",
'type' =>         "select",
'options' =>      "select,ÃŽÅ"ε Ïâ,¬ÃÂÃŽÂ¿Ãâ€ Ãâ€¦ÃŽÂ»ÃŽÂ±ÃŽÂºÃâ€žÃŽÂ¹ÃŽÂºÃŽÂ¿,Χωρις Ïâ,¬ÃÂÃŽÂ¿Ãâ€ Ãâ€¦ÃŽÂ»ÃŽÂ±ÃŽÂºÃâ€žÃŽÂ¹ÃŽÂºÃŽÂ¿",
'defaultvalue' => "1",
'required' =>     1
),
                                  array(
'caption' =>      "A-level (Ïâ,¬ÃÂÃâ€°ÃŽÂºÃâ€žÃŽÂ¹ÃŽÂºÃÅ')",
'name' =>         "feedback3",
'type' =>         "select",
'options' =>      "select,ναι,οχι",
'defaultvalue' => "1",
'required' =>     1
),
                                  array(
'caption' =>      "ΕκÏÆ'Ïâ,¬ÃŽÂµÃÂÃŽÂ¼ÃŽÂ¬Ãâ€žÃâ€°ÃÆ'η",
'name' =>         "feedback4",
'type' =>         "select",
'options' =>      "select,Στο ÏÆ'ωμα,Στο Ïâ,¬ÃÂÃŽÂ¿ÃÆ'ωÏâ,¬ÃŽÂ¿,Στο ÏÆ'τομα (τα φτυνει),Στο ÏÆ'τομα (τα καταÏâ,¬ÃŽÂ¹ÃŽÂ½ÃŽÂµÃŽÂ¹)",
'defaultvalue' => "1",
'required' =>     1
),
array(
'caption' =>      "ΣχέÏÆ'η αÏâ,¬ÃÅ'δοÏÆ'ης/τιμής",
'name' =>         "check",
'type' =>         "select",
'options' =>      "select,3,4,5,6,7,8,9,10",
'defaultvalue' => "1",
'required' =>     1
), 
                                 array(
'caption' =>      "Θα ξαναεβλεÏâ,¬ÃŽÂµÃâ€š την κοÏâ,¬ÃŽÂµÃŽÂ»ÃŽÂ±?",
'name' =>         "feedback",
'type' =>         "select",
'options' =>      "select,Ναι,Οχι,MÏâ,¬ÃŽÂ¿ÃÂÃŽÂµÃŽÂ¹, δεν εχω αÏâ,¬ÃŽÂ¿Ãâ€ ÃŽÂ±ÃÆ'ιÏÆ'ει ακομα..",
'defaultvalue' => "1",
'required' =>     1
), 

array(
'caption' =>      "Overall",
'name' =>       "comments",
'type' =>         "textarea",
'options' =>      "",
'defaultvalue' => "",
'required' =>     1
),

);

$topicOptions = array(
'id' => $_REQUEST['topic'] ,
'board' => $board_id,
'poll' =>  null,
'lock_mode' =>  null,
'sticky_mode' =>  null,
'mark_as_read' => true,
);

$thanks_text = "ΕυχαριÏÆ'τουμε για την κριτικη! ";




//send the application by email?
$enable_email=false;

// email address of recruitment staff member
$email_address='';

//post the application on forum?
$enable_post=true;

//board id to which the application should be posted
$board_id=2;


//END OF CONFIGURATION SECTION
////////////////////////////////////////////////////////////////////////////////////////////


$show_form= 'true';
if (isset($_REQUEST['submitted'])) {  // Handle the form
// Check required fields
$errors = array(); //Initialize error array

foreach ($fielddef as $field)
if (empty($_REQUEST[$field['name']]) && ($field['required'] == 1)){ $errors[] = $field['name']; }

// There's at least one field missing
if (isset($errors[0])) {
foreach ($_REQUEST as $key => $value)
$fieldvalue[$key] = $value;
}
else { // all is well
 
$show_form='false';

if ($enable_email) {  // email an application
$subject = 'Application';
$body = '';
foreach ($fielddef as $field) {
if ($field['type'] == 'heading')
$body .= $field['caption'] . '
';
else
$body .= $field['caption'] . ': ' . $_REQUEST[$field['name']] . '
';
}
mail($email_address, $subject, $body,"From: " . $user_info['email']);
}

if ($enable_post) {  //create new forum post with application



$topic = $_GET['topic'];
$result = db_query("SELECT m.subject
FROM {$db_prefix}messages as m, {$db_prefix}topics as t
WHERE m.ID_TOPIC = $topic
AND t.ID_FIRST_MSG = m.ID_MSG", __FILE__, __LINE__);

$row = mysql_fetch_assoc($result);
$subject = $row['subject'];
mysql_free_result($result);

$postbody = 'ΕυχαριÏÆ'τουμε για την κριτικη ' . $context['user']['name'] .'<br /><br/>';
foreach ($fielddef as $field) {
                                       if ($field['type'] == 'heading')
$postbody .= $field['caption'] . '<br />';
elseif ($field['caption'] == 'Comments')
$postbody .= '[b][color=red]' . $field['caption'] . '[/color][/b]: ' . $_REQUEST[$field['name']] . '<br />';
else
$postbody .= '[b]' . $field['caption'] . '[/b]: ' . $_REQUEST[$field['name']] . '<br />';
}
$msgOptions = array(
'id' =>  0 ,
'subject' => 'Re: ' . $subject,
'body' => addslashes($postbody) ,
'icon' => 'xx',
'smileys_enabled' => true,
'attachments' =>  array(),
);
$topicOptions = array(
'id' => $_GET['topic'] ,
'board' => $board_id,
'poll' =>  null,
'lock_mode' =>  null,
'sticky_mode' =>  null,
'mark_as_read' => true,
);
$posterOptions = array(
'id' => $context['user']['id'],
'name' => $context['user']['name'],
'email' => $user_info['email'],
'update_post_count' => true,
);
createPost($msgOptions, $topicOptions, $posterOptions);
}
// Text for thank you page
echo $thanks_text;
}
}
else {
foreach ($fielddef as $field) {
$fieldvalue[$field['name']] = $field['defaultvalue'];
}
}



// Looks like you want the form,
if ($show_form == 'true') {
echo $intro_form . "<br>";
if (isset($errors[0])) { echo '<div style="color: red;">Please fill in all fields with a *.</div>';  }

$place = $_SERVER['REQUEST_URI'];
echo '
<form action="' . $place . '" method="post">
<INPUT name="submitted" type="hidden" value="TRUE" />
        <table style="margin-left:auto; margin-right:auto;">';

$bg = 'windowbg2';

foreach ($fielddef as $field) {
// Headings have their own type of display
if ($field['type'] == 'heading') {
echo '
<TR>
<TD colspan="2" style="text-align: center; font-weight:bold;">' .
$field['caption'] . '
</TD>
</TR>';
}

else {

// How each field is displayed in the table
echo '
<TR class ="' . $bg . '">
<TD align="right">';
              if ($field['required'] == 1) { echo '* '; }
              echo $field['caption'] . ':
</TD>
<TD align="left">';

// Go through each field type
if ($field['type'] == 'text') {
echo '<INPUT name="' . $field['name'] . '" type="text" value ="' . $fieldvalue[$field['name']] . '" />';
}
elseif ($field['type'] == 'radio') {
$options = explode(',',$field['options']);
foreach ($options as $option) {
echo '<INPUT TYPE="RADIO" NAME="' . $field['name'] . '" VALUE="'. $option . '"';
if ((isset($fieldvalue[$field['name']])) && ($option == $fieldvalue[$field['name']])) { echo ' CHECKED'; }
echo '>' . $option . ' ';
}
}
elseif ($field['type'] == 'checkbox') {
echo '<INPUT TYPE="CHECKBOX" NAME="' . $field['name'] . '" VALUE="'. $field['options'] . '"';
if (isset($fieldvalue[$field['name']]) && ($fieldvalue[$field['name']]==$field['options'])) { echo ' CHECKED'; }
echo '>' . $field['options'];   
}
elseif ($field['type'] == 'select') {
echo '<SELECT name="' . $field['name'] . '" />';
$options = explode(',',$field['options']);
foreach ($options as $option) {
echo '<OPTION value="' . $option . '"';
if ((isset($fieldvalue[$field['name']])) && ($option == $fieldvalue[$field['name']])) { echo ' selected'; }
echo '>' . $option . '</OPTION>';
}
echo '</SELECT>';
}   
elseif ($field['type'] == 'textarea') {
echo '<TEXTAREA name="' . $field['name'] . '" rows="6" cols="50">';
echo $fieldvalue[$field['name']];
echo '</' . 'TEXTAREA>';
}

// Finish off the row
echo '
</TD>
</TR>';
}

// Set up the alternating colors for the next row
($bg == 'windowbg2') ? $bg = 'windowbg' : $bg = 'windowbg2';
}

echo '
<TR class ="' . $bg . '">
<TD colspan="2" align="center">
<INPUT type="submit" value="Submit">
<INPUT type="reset" value="Reset">
</TD>
</TR>
</TABLE>
</form>';
}
}
SMF  1.1.11 / TinyPortal v1.0 beta 4 /default theme

ZarPrime

Quote from: ed_m on September 25, 2009, 11:16:49 AM
out of interest... is there any permission checking on the topic posting option ?

if i use this then the topic will be sent to a private board before being approved and moved to a public board.

so if the submitter does not have access to the private board will it still post the message ?

ed_m,

The original intent of this code was as an application form that could be filled out by a member that would start a new topic in a board.  The board need not be visible to the poster but it could just as easily be visible.  You set the board that the new topic is placed into in the code.  There is also a way in the code to send the Admin an EMail when the form is filled out and submitted.

ZarPrime

JPDeni

EasyRider, you have the code right. I don't know what the problem could be. I'm sorry.

Freddy

#107
This bit....

if ($field['type'] == 'heading')
$postbody .= $field['caption'] . '<br />';
elseif ($field['caption'] == 'Comments')
$postbody .= '[b][color=red]' . $field['caption'] . '[/color][/b]: ' . $_REQUEST[$field['name']] . '<br />';
else
$postbody .= '[b]' . $field['caption'] . '[/b]: ' . $_REQUEST[$field['name']] . '<br />';


Does he actually have a field called "Comments" ?

The way I read it the red will only display if the field is specifically named 'Comments'...so I am thinking he would need to test for each and every heading type that he wants to be red.

Hmmm  :-\

JPDeni

Good call, freddy! It didn't even occur to me.

EasyRider, you need to change the caption to match the field you have. It would be, I guess


elseif ($field['caption'] == 'Overall')


ed_m2


This website is proudly hosted on Crocweb Cloud Website Hosting.