News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Custom Form Mod

Started by live627, July 09, 2008, 10:24:44 PM

Previous topic - Next topic

Garou

TweakerL, I did make a note of your post count fix and I plan to implement it in the next version, hopefully with the ability to recognize the board permissions for post count.

As for implementing code to account for features of other mods, that's not something I want to get into doing. First and for most because it does cause unnecessarily bloat in the code and could slowdown peoples servers especially if they don't have the mod.  More importantly if I started adding features for all the different mods that could improve this mod Id never have time to do much else. :)

Having the code available in this thread is a boon though, that way if someone wants to add it for their own site they can.

As for the issue with the img and url tags that is specifically a 1.1.x problem, it has something to do with the way SMF works and has been a problem for the mod since the beginning. When the mod was written for 2.0 the same code was used to call those tags but doesn't have the problem, I'm still looking into it though. :)

Tunga

#1041
Here's my fix for the selection box issue.

Find (around line 76):
foreach ($field_data['data'] as $option)
echo '
<option value="', $option, '"', ($option == $field_data['value'] ? ' selected="selected"' : ''), '>', $option, '</option>';


Replace with:
foreach ($field_data['data'] as $option)
if ($option != 'required')
echo '
<option value="', $option, '"', ($option == $field_data['value'] ? ' selected="selected"' : ''), '>', $option, '</option>';
else
echo '
<option value=""></option>';


What this does is to simply replace any instances of "required" (sans quotes) in the list of options with a blank option.  Therefore if you put required as the first entry you get a blank option at the top which is then selected by default.  If the user submits without selecting a non-blank option then the existing code rejects it anyway so no other changes are needed.  This is a quick fix and I expect not how you would want to implement it in the actual mod but maybe some other users will find it useful.  It is at least a quick and easy change and shouldn't break anything else.

Thanks again, great mod :) .

ŦώεαЖзяŁ

I just mentioned the change to make it update the post count again because jkfriends asked how to do it after i had explained, so I guess he didn't see it before :)...

Link Sharing Community - Share links and earn cash in the process!
APPS | GAMES | MUSIC | MOVIES | TV SHOWS | E-BOOKS

FragaCampos

Quote from: TweakerL on January 05, 2010, 01:14:59 AM
Like I said back on page 50 to force all forms to update the post count of users simply add

Quote'update_post_count' => !$user_info['is_guest'],

after

Quote$posterOptions = array(
                   'id' => $user_info['id'],

in Sources/CustomForm.php

Hi TweakerL. I don't have that in my CustomForm.php, maybe because i'm still using v 1.1.5 of the mod. Can you point me how to do this?
What i have is this
$posterOptions = array(
'id' => $ID_MEMBER,
);


Quote from: TweakerL on January 05, 2010, 01:14:59 AM
...jkfriends, I'm not sure if you already fixed it, but my custom forms are not having http:// added automatically inside [ img ] tags; any chance you have another mod that could be doing that?

Hmm, you're using smf 2, right?

ŦώεαЖзяŁ

Yes I'm using SMF2 RC2...

As for how to do the fix on 1.x, I'm not entirely certain how you would go about it. I'll tell you how I figured it out, and you can try the same process.

Go to your Sources/Post.php and try to find the createPost function. I'm not sure if it's called exactly that but I'm guessing it is.

It will be something like this:
QuotecreatePost($msgOptions, $topicOptions, $posterOptions);

You wanna see what the $posteroptions for your post.php is called, in 2.0 it's called $posteroptions. Now you want to search for that inside of Post.php until you find something like this

Quote$posterOptions = array(
      'id' => $user_info['id'],
      'name' => $_POST['guestname'],
      'email' => $_POST['email'],
      'update_post_count' => !$user_info['is_guest'] && !isset($_REQUEST['msg']) && $board_info['posts_count'],

You wanna figure out what 'update_post_count' is called for your version, so look for the line most similar to the one above. It will most likely have 3 conditionals like the one above, one to make sure the user is not guest (!$user_info['is_guest']) one to make sure that the message is new !isset($_REQUEST['msg']) and one to check that the board has post count ($board_info['posts_count']). You wanna take note of of conditional for the user not being a guest.

Now that you know that your $posteroptions is called, what your update_post_count is called and what your notguest conditional is called, you wanna go into CustomForm.php and search for the name you have for $posteroptions. It will look something like this:

Quote$posterOptions = array(
               'id' => $user_info['id'],

You wanna add one line under it that says:
Quote'update_post_count' => !$user_info['is_guest']

Of course you want to replace each of the 3 colored things with whatever your version is using. The red one should be the same thing you see in the line above, that's basically the set variable operator.

Conversely, if you think this is too difficult feel free to post both your post.php and your customform.php here, if Garou doesn't mind, and i'll look at it and see if I can tell exactly what to change

Link Sharing Community - Share links and earn cash in the process!
APPS | GAMES | MUSIC | MOVIES | TV SHOWS | E-BOOKS

FragaCampos

First, i want to thank you for your 5* detailed explanation. Although i'm a complete newbie i understood everything and it worked. The form posts are now counting.
So the solution for the 1.1.x versions is:

find in /Sources/CustomForm-php
$posterOptions = array(
               'id' => $user_info['id'],


and replace with
$posterOptions = array(
               'id' => $user_info['id'],
'update_post_count' => !$user_info['is_guest']


Thank you very much ŦώεαЖзяŁ  ;)

ŦώεαЖзяŁ

Quote from: FragaCampos on January 07, 2010, 08:00:19 PM
find in /Sources/CustomForm-php
$posterOptions = array(
               'id' => $user_info['id'],


and replace with
$posterOptions = array(
               'id' => $user_info['id'],
'update_post_count' => !$user_info['is_guest']


Thank you very much ŦώεαЖзяŁ  ;)

Glad to help, just remember that as I said, this fix won't check if the board has post_count enabled, it will just count even if it's not enabled for the specific board. The reason for this is that I haven't figured out how to make the $board_info['posts_count'] variable check work, just calling it makes the count not work at all. If I figure it out, I'll post it here :)

Link Sharing Community - Share links and earn cash in the process!
APPS | GAMES | MUSIC | MOVIES | TV SHOWS | E-BOOKS

FragaCampos

That would be surely important to others, but in my case there's no problem, since i have post count enabled everywhere ;)

Jaymjaym

Hello folks, I've recently installed this mod and have run into an error. I'll post the error at the end of the message. This is occurring when I try to view a form I have created. This post is somewhat empty as I have no idea what info you need for the troubleshoot, but I'll provide whatever you need. :)

QuoteNot Acceptable

An appropriate representation of the requested resource /forums/index.php could not be found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

ŦώεαЖзяŁ

when you installed it through the packages manager, did it say there were any errors?

what version of SMF do you have?

Link Sharing Community - Share links and earn cash in the process!
APPS | GAMES | MUSIC | MOVIES | TV SHOWS | E-BOOKS

Garou

Jaymjaym, generally SMF version, Mod version, a list of other mods on the forum, and a link to the site would be helpful when asking for support with any mod.

That said it looks like it could be that your host is running ModSecurity which has been known to produce similar errors. You might want to check the logs for your site and see if it says anything about GET errors with either CustomForm.php or CustomForm.template.php. If it does you'll have to ask your host to white list those files in ModSecurity. Instructions on how to do that can be found at http://blog.modsecurity.org/2007/02/handling-false.html

Jaymjaym

#1051
Quote from: ŦώεαЖзяŁ on January 09, 2010, 07:23:42 PM
when you installed it through the packages manager, did it say there were any errors?

what version of SMF do you have?

Quote from: Garou on January 09, 2010, 10:59:47 PM
Jaymjaym, generally SMF version, Mod version, a list of other mods on the forum, and a link to the site would be helpful when asking for support with any mod.

That said it looks like it could be that your host is running ModSecurity which has been known to produce similar errors. You might want to check the logs for your site and see if it says anything about GET errors with either CustomForm.php or CustomForm.template.php. If it does you'll have to ask your host to white list those files in ModSecurity. Instructions on how to do that can be found at http://blog.modsecurity.org/2007/02/handling-false.html [nofollow]

hey folks, thanks for the quick response.

@ŦώεαЖзяŁ, It install without any errors through package manager. Also, the SMF version is 1.1.11


@Garou, Mod version is 1.6, Other form mods are:

SMF Arcade      2.0.18
Tar Game Uploader      1.0
(Note that both of these were install after I posted here originally, so probably shouldn't be contributing to the error)

Forums are here: http://cn-gondor.net/forums/index.php [nofollow]

I don't seem to see anything in the error logs regarding what you mentioned.

bros

Have a bit of an issue with the newest version on SMF 2 RC 1.2

I can't see any of the forms I made on the old version of Custom Form Mod in the admin panel (I can see them in action=form, though)

Here are the errors in the error log:
2: Invalid argument supplied for foreach()
File: /home/xxxx/public_html/boards/Sources/Subs-List.php
Line: 120

2: call_user_func_array() [<a href='function.call-user-func-array'>function.call-user-func-array</a>]: First argument is expected to be a valid callback, 'list_CustomForms' was given
File: /home/xxxx/public_html/boards/Sources/Subs-List.php
Line: 116

8: Undefined variable: scripturl
File: /home/xxxxx/public_html/boards/Themes/default/languages/Modifications.english.php
Line: 395 (also lines 297, 296, 156, 155)

Garou

Jaymjaym, did you check your site logs or your forum logs? what kind of errors are you getting if any?

Bros, this mod doesn't edit the Subs-List.php so I'm not sure whats going on there. Have you compared your language files to the install? Also did you accidentally install the version for RC2 instead of 2.x? The two files have some differences as RC2 has some specific code changes.  Also youll probably want to update your site to RC2 for security reasons also future versions of this mod will no longer support versions of SMF 2.0 prior to RC2.

bros

Quote from: Garou on January 10, 2010, 09:05:27 PM
Jaymjaym, did you check your site logs or your forum logs? what kind of errors are you getting if any?

Bros, this mod doesn't edit the Subs-List.php so I'm not sure whats going on there. Have you compared your language files to the install? Also did you accidentally install the version for RC2 instead of 2.x? The two files have some differences as RC2 has some specific code changes.  Also youll probably want to update your site to RC2 for security reasons also future versions of this mod will no longer support versions of SMF 2.0 prior to RC2.

Then it must be another one of the mods that is messing with subs-list, how unusual.

I'll update to RC2 after a few essential mods get updated.

Wh1teLeopard

Hiya!

I'm really sorry if this has already been covered I read a lot of the pages at the start and end, and did a search of the topic but couldn't find my answer.

I wouldn't be surprised if it's something simple and daft that I've not done, but I created a form, assigned it etc and it posts a new topic, but that topic is blank.

I tried typing in the names of the fields but I guess I'm doing it wrong.

Did a manual install for SMF 2.0 RC2, only other install is Custom Page and Tab from the mods section.
www.keikarsinthepark.co.uk - The annual meet for kei car owners.

Garou

Where it says subject.

From the help file for that field...
QuoteThis is the subject/title of the post created by the form, like the Form Output area, it can contain values from the form itself.

Example:
Form name: {field_name}

Wh1teLeopard

Ah ha! Case sensitive d'uh! Thanks for the help :)

Sorry guys... back to the naughty corner for me!
www.keikarsinthepark.co.uk - The annual meet for kei car owners.

bros

Quote from: Garou on January 10, 2010, 09:05:27 PM
Jaymjaym, did you check your site logs or your forum logs? what kind of errors are you getting if any?

Bros, this mod doesn't edit the Subs-List.php so I'm not sure whats going on there. Have you compared your language files to the install? Also did you accidentally install the version for RC2 instead of 2.x? The two files have some differences as RC2 has some specific code changes.  Also youll probably want to update your site to RC2 for security reasons also future versions of this mod will no longer support versions of SMF 2.0 prior to RC2.

Can you think of why the lists aren't displaying in the admin panel?

Garou

QuoteHave you compared your language files to the install?

Using SMF's parser for the 2.x version of the mod http://custom.simplemachines.org/mods/index.php?action=parse;mod=1279;attach=122917;smf_version=2.0_RC1.2

Modifications.english.php and Help.english.php should be edited in the language folder of the default theme and if they exist then in any other custom theme you may be using. If those files aren't in the language folders for your theme then SMF is supposed to be pulling them from the default theme but sometimes this doesn't happen and you may want to copy the files from your default theme to any custom themes.


Advertisement: