Advertisement:

Author Topic: Custom Form Mod  (Read 501657 times)

Offline SychO

  • Jr. Member
  • **
  • Posts: 162
Re: Custom Form Mod
« Reply #1760 on: September 04, 2016, 03:53:39 PM »
this is much better

in ManageSettings.php

find
Code: [Select]
                $smcFunc['db_query']('', '
DELETE FROM {db_prefix}permissions
WHERE id_group = {int:current_group}
' . (empty($context['illegal_permissions']) ? '' : ' AND permission NOT IN ({array_string:illegal_permissions})'),
array(
'current_group' => $_GET['group'],
'illegal_permissions' => !empty($context['illegal_permissions']) ? $context['illegal_permissions'] : array(),
)
);

replace WHERE with:

Code: [Select]
WHERE permission NOT LIKE "custom_forms%" AND permission NOT LIKE "CustomForm_view_perms" AND

Omg i am so sorry i meant ManagePermissions.php but wrote ManageSettings.php

Offline aegersz

  • Sophist Member
  • *****
  • Posts: 1,065
  • Gender: Male
  • "mods" junkie
    • dopetalk
Re: Custom Form Mod
« Reply #1761 on: September 06, 2016, 04:15:36 PM »
when i try this mod in my dev system, the topic that it generates doesn't include the fields that i filled in.

am i doing it right ?

where does my entered data go ?

EDIT: Sorted now, i forgot to add the "{field}" value into the body
« Last Edit: September 06, 2016, 04:26:11 PM by aegersz »
SMF 2.0: 135+ mods installed (the full list can be seen at http://forum.drugs-and-users.org/index.php/topic,3301)

Offline Snrj

  • Jr. Member
  • **
  • Posts: 253
  • Gender: Male
  • smf forum
    • Smf Destek

Offline iViscosity

  • Newbie
  • *
  • Posts: 4
Re: Custom Form Mod
« Reply #1763 on: December 13, 2016, 11:11:35 PM »
I need some help, if anyone still can. I used the guide to make the 'new topic' redirect to the form, but when I click 'save' at the end of the form, it just goes back to the empty form and no post is made. How can I fix this?

Offline thunderchld

  • Semi-Newbie
  • *
  • Posts: 33
Re: Custom Form Mod
« Reply #1764 on: March 01, 2017, 04:53:46 PM »
I have attempted to go through the posts, but I cannot find it.  Is it possible to have the forum post anonymously? (Paired with another mod is fine).

e.g. we have a form to collect feedback after certain events; but we do not want everyone to know who sent in that feedback.

Offline VenoM9078

  • Newbie
  • *
  • Posts: 1
Re: Custom Form Mod
« Reply #1765 on: August 07, 2017, 08:32:27 AM »
I'm sorry for bumping this thread. But I don't know where else can I go for help. It's really important for me to solve this..

When I install the Custom Form Mod and redirect to the 'settings' page as it recalls, this error comes up:

Quote
Fatal error: Redefinition of parameter $nul in /storage/ssd1/304/2487304/public_html/Sources/ManageSettings.php on line 2693

Where 2693 line is:

Code: [Select]
// Fucntion to produce a list of custom form fields.
function list_CustomForm_fields($nul, $nul, $nul, $id)
{
global $txt, $scripturl, $smcFunc;

// Get the data from the cf_fields table.
$request = $smcFunc['db_query']('','
SELECT id_field, title, type, text
FROM {db_prefix}cf_fields
WHERE id_form = {int:id_form}
ORDER BY id_field',
array(
'id_form' => $id,
)
);

$data = array();

while($row = $smcFunc['db_fetch_assoc']($request))
$data[] = $row;

$list = array();
$i = 1;
$end = count($data);

I don't know how to resolve this error. Was hoping someone can help? I only have 2 other packages installed including "mentioning @members" and a smiley pack.

Offline Atomixx

  • Semi-Newbie
  • *
  • Posts: 21
Re: Custom Form Mod
« Reply #1766 on: August 09, 2017, 03:33:08 PM »
Anyone know a way that I can make one of the Text Boxes be automatically filled with the users username and cannot be changed?

Offline Eiyuu

  • Newbie
  • *
  • Posts: 1
Re: Custom Form Mod
« Reply #1767 on: August 17, 2017, 07:52:42 PM »
Hi everyone,

I am trying to make the custom form to also work on replies.

I have managed to get do Display.template.php and modify it to go to a custom form, but it always does a new topic instead of replying to the current topic.

My objective was to even use the same form, on the same board. If the same form doesn't work i will just duplicate the form and use that for a reply (which is what i have been trying to do without success...)

Can someone give me a few pointers in how i can make it work for replies as well?

Thanks

Offline wwwserfer

  • Semi-Newbie
  • *
  • Posts: 34
Re: Custom Form Mod
« Reply #1768 on: October 05, 2017, 07:48:41 AM »
this is much better

in ManageSettings.php

find
Code: [Select]
                $smcFunc['db_query']('', '
DELETE FROM {db_prefix}permissions
WHERE id_group = {int:current_group}
' . (empty($context['illegal_permissions']) ? '' : ' AND permission NOT IN ({array_string:illegal_permissions})'),
array(
'current_group' => $_GET['group'],
'illegal_permissions' => !empty($context['illegal_permissions']) ? $context['illegal_permissions'] : array(),
)
);

replace WHERE with:

Code: [Select]
WHERE permission NOT LIKE "custom_forms%" AND permission NOT LIKE "CustomForm_view_perms" AND

Omg i am so sorry i meant ManagePermissions.php but wrote ManageSettings.php

4 SMF 1.1.x

In ManagePermissions.php

Find:

Code: [Select]
// Insert the general permissions.
if ($_GET['group'] != 3 && empty($_GET['boardid']))
{
db_query("
DELETE FROM {$db_prefix}permissions
WHERE permission NOT LIKE 'custom_forms%' AND permission NOT LIKE 'CustomForm_view_perms' AND ID_GROUP = $_GET[group]" . (empty($context['illegal_permissions']) ? '' : "
AND permission NOT IN ('" . implode("', '", $context['illegal_permissions']) . "')"), __FILE__, __LINE__);

replace WHERE with:

Code: [Select]
WHERE permission NOT LIKE 'custom_forms%' AND permission NOT LIKE 'CustomForm_view_perms' AND
It will be right?

(At least it helped me) ;)

Offline ryry46d9

  • Semi-Newbie
  • *
  • Posts: 12
Re: Custom Form Mod
« Reply #1769 on: October 09, 2017, 11:58:31 AM »
Any chance for live627 to come out of retirement ...

Forum version: SMF 2.0.14
I did a local install to track that broke my forums and so far it looks like Custom Form Mod 1.7 is the culprit (only mod installed)

For some reason when CFM is installed I have no access to:
Core Features
Features and Options
Security and Moderation
Modification Settings
Error Log
Administration Log
Moderation Log
Ban Log
Spider Log
Task Log
Log Pruning
When I try to access the pages I get a error 500 with chrome and a blank page with firefox

Also found this gem sitting in the Error Log :
http://192.168.1.100/public/index.php?action=admin;area=packages;sa=install;package=CustomFormMod_v1.7_SMF2x.zip [nofollow]
8: Undefined index: package_readme
File: /var/www/html/public/Sources/Packages.php
Line: 356

Offline Proderf

  • Semi-Newbie
  • *
  • Posts: 14
Re: Custom Form Mod
« Reply #1770 on: October 10, 2017, 09:59:06 PM »
From what I notice, this mod doesn't bode well with 2.0.14

I have an error where I can access and use the template, but if i go to edit them, it error screens in the forums saying "The database value you're trying to insert does not exist: id_form"

EDIT: Ive done some of my own tweaking, and the problem comes from ~line 2700 and its previous similar lines with "function list************($nul, $nul, $nul, $id)"

This give an overall fatal error "redefined parameter $nul"

Fix 1: change "function list************($nul, $nul, $nul, $id)" to "function list************()"
-This give the id error stated above

Fix 2:  change "function list************($nul, $nul, $nul, $id)" to "function list************($id)"
-This lets you see the edit page of the forums, but does not show the fields used; its as though there are no feeds on the form, HOWEVER, hone you use the form the fields are still there.

My hypothesis is that 2.0.14 has a bug with mods and databases, where the coding of the mod is not properly pulling from the database the mod data is stored in


Here is my current code (I'm mostly concerned with the second half of it)
Code: [Select]
// Fucntion to produce a list of custom forms.
function list_CustomForms($id)
{
global $txt, $scripturl, $smcFunc;

// Get the data from the cf_forms table.
$request = $smcFunc['db_query']('','
SELECT id_form, title, id_board
FROM {db_prefix}cf_forms'
);

// Get some general permissions info.
$permissions = get_CustomForm_permissions();
$membergroups = get_CustomForm_membergroups();
$list = array();

// Go through every form.
While($row = $smcFunc['db_fetch_assoc']($request))
{
// Create a list of the groups which can use this form.
$permissions_string = $txt['admin'];
if(isset($permissions['custom_forms_'.$row['id_form']]))
foreach($permissions['custom_forms_'.$row['id_form']] as $membergroup_id)
$permissions_string .= ', '.$membergroups[$membergroup_id];

// Try to find the name of the board.
$board_name = 'Invalid Board';

$board_request = $smcFunc['db_query']('','
SELECT name
FROM {db_prefix}boards
WHERE id_board = {int:id_board}
AND redirect = \'\'',
array(
'id_board' => $row['id_board'],
)
);

// Try to get the name from the returned row.
if($board = $smcFunc['db_fetch_assoc']($board_request))
$board_name = $board['name'];
$smcFunc['db_free_result']($board_request);

// Add the current entry into the list.
$list[] = array(
'title' => $row['title'],
'board' => $row['id_board'].' ("'.$board_name.'")',
'permissions' => $permissions_string,
'modify' => '
<table width="100%">
<tr>
<td width="50%" style="text-align:center;">
<a href="'.$scripturl.'?action=admin;area=modsettings;sa=customform;form_id='.$row['id_form'].';">
('.$txt['CustomForm_edit'].')
</a>
</td>
<td width="50%" style="text-align:center;">
<a href="'.$scripturl.'?action=admin;area=modsettings;sa=customform;form_id='.$row['id_form'].';delete;" onclick="return confirm(\''.$txt['CustomForm_delete_warning'].'\')" >
('.$txt['delete'].')
</a>
</td>
</tr>
</table>',
);
}
$smcFunc['db_free_result']($request);
return $list;
}

// Fucntion to produce a list of custom form fields.
function list_CustomForm_fields($id)
{
global $txt, $scripturl, $smcFunc;

// Get the data from the cf_fields table.
$request = $smcFunc['db_query']('','
SELECT id_field, title, type, text
FROM {db_prefix}cf_fields
WHERE id_form = {int:id_form}
ORDER BY id_field',
array(
'id_form' => $id,
)
);

$data = array();

while($row = $smcFunc['db_fetch_assoc']($request))
$data[] = $row;

$list = array();
$i = 1;
$end = count($data);

// Go through every field.
foreach($data as $field)
{
// Convert the field type into the proper text strings.
$type = str_replace(
// Search array.
array('largetextbox', 'textbox', 'checkbox', 'selectbox', 'float', 'int', 'radiobox', 'infobox'),
// Replace array.
array( $txt['CustomForm_large_textbox'], $txt['CustomForm_textbox'], $txt['CustomForm_checkbox'], $txt['CustomForm_selectionbox'], $txt['CustomForm_float'], $txt['CustomForm_int'], $txt['CustomForm_radiobox'], $txt['CustomForm_infoboxa']),
$field['type']
);

// Add the current entry into the list.
$list[] = array(
'title' => $field['title'],
'text' => $field['text'],
'type' => $type,
'modify' => '
<table width="100%">
<tr>
<td width="25%" style="text-align:center;">
<a href="'.$scripturl.'?action=admin;area=modsettings;sa=customform;field_id='.$field['id_field'].';moveup;">
'.(($i != 1) ? '('.$txt['CustomForm_moveup'].')' : '').'
</a>
</td>
<td width="25%" style="text-align:center;">
<a href="'.$scripturl.'?action=admin;area=modsettings;sa=customform;field_id='.$field['id_field'].';movedown;" >
'.(($i != $end) ? '('.$txt['CustomForm_movedown'].')' : '').'
</a>
</td>
<td width="50%" style="text-align:center;">
<a href="'.$scripturl.'?action=admin;area=modsettings;sa=customform;field_id='.$field['id_field'].';">
('.$txt['CustomForm_edit'].')
</a>
</td>
<td width="50%" style="text-align:center;">
<a href="'.$scripturl.'?action=admin;area=modsettings;sa=customform;field_id='.$field['id_field'].';delete;" onclick="return confirm(\''.$txt['CustomForm_delete_warning'].'\')" >
('.$txt['delete'].')
</a>
</td>
</tr>
</table>',
);
$i++;
}
$smcFunc['db_free_result']($request);
return $list;
}

« Last Edit: October 10, 2017, 10:45:00 PM by Proderf »

Online Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 54,914
  • Gender: Male
    • Kindred-999 on GitHub
Re: Custom Form Mod
« Reply #1771 on: October 10, 2017, 11:22:05 PM »
Since there are many other mods that store and pull information from the database, with no issues, your hypothesis is pretty certainly Incorrect
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline Proderf

  • Semi-Newbie
  • *
  • Posts: 14
Re: Custom Form Mod
« Reply #1772 on: October 11, 2017, 06:37:35 PM »
Since there are many other mods that store and pull information from the database, with no issues, your hypothesis is pretty certainly Incorrect


thanks for the help :)

what i meant is that the mod itself is not pulling properly; this only started happening with 2.0.14

Online Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 54,914
  • Gender: Male
    • Kindred-999 on GitHub
Re: Custom Form Mod
« Reply #1773 on: October 11, 2017, 10:30:55 PM »
2.0.14 did change some things for php7 and supporting https. So, there is a chance that this mod will have to be updated
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline Proderf

  • Semi-Newbie
  • *
  • Posts: 14
Re: Custom Form Mod
« Reply #1774 on: October 14, 2017, 11:35:36 AM »
That's probably accurate. The mod worked before 2.0.14 so it probs just needs a bit of tweaking.