Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Mod Requests => Topic started by: Texan78 on May 15, 2012, 01:20:05 PM

Title: Download System
Post by: Texan78 on May 15, 2012, 01:20:05 PM
Hello,

I am using this mod http://custom.simplemachines.org/mods/index.php?mod=992 and it is exactly what I need but I need a small tweak that I was wondering if it was possible and if someone could offer some assistance with. 

What I am looking for is when a download is created it will create a post in a certain board I choose with the topic being the downloads title, but the first post contents will be that of the downloads description.


Any way this can be done?

-Thanks!

Title: Re: Download System
Post by: vbgamer45 on May 15, 2012, 01:26:33 PM
That should mostly be built already inside that mod. Under edit category you have the option to choose which board to post to.
Title: Re: Download System
Post by: Texan78 on May 15, 2012, 01:45:58 PM
Thank you for the quick response. My apologizes, I think I described it wrong. You are correct, you can set it to post to certain board. As it is now unless there is something I am missing it only posts a link in that post to the downloads section. If possible it would be really really nice for it to also post the description of the download in addition of the link to the download below it. How would this be possible?

-Thanks!
Title: Re: Download System
Post by: vbgamer45 on May 15, 2012, 06:59:57 PM
Modify the Downloads.php in the Sources folder look at the AddDownload2 function and find the createpost function and add have it include the description of the download into  message body of that function call
Title: Re: Download System
Post by: Texan78 on May 15, 2012, 07:23:15 PM
Whewww, I'm not a coder so that may be a tad over my expertise, but I can find my way around ok so I will give it a shot since I have some direction now. Please stand by and I will update with the progress if I was able to get it..LoL

-Thanks!
Title: Re: Download System
Post by: Texan78 on May 15, 2012, 09:46:29 PM
Would this be the Downloads2.php? I don't have a Downloads.php in my Sources folder?

-Thanks
Title: Re: Download System
Post by: Texan78 on May 15, 2012, 10:04:55 PM
Quote from: vbgamer45 on May 15, 2012, 06:59:57 PM
Modify the Downloads.php in the Sources folder look at the AddDownload2 function and find the createpost function and add have it include the description of the download into  message body of that function call

Here is the AddDownload two function but I can not fine the createpost function.

function Downloads_AddDownload()
{
global $context, $mbname, $txt, $modSettings, $user_info, $smcFunc, $sourcedir;

isAllowedTo('downloads_add');

if (isset($_REQUEST['cat']))
$cat = (int) $_REQUEST['cat'];
else
$cat = 0;

$context['down_cat'] = $cat;

Downloads_GetCatPermission($cat,'addfile');

if ($user_info['is_guest'])
$groupid = -1;
else
$groupid =  $user_info['groups'][0];

$dbresult = $smcFunc['db_query']('', "
SELECT
c.ID_CAT, c.title, p.view, p.addfile
FROM {db_prefix}down_cat AS c
LEFT JOIN {db_prefix}down_catperm AS p ON (p.ID_GROUP = $groupid AND c.ID_CAT = p.ID_CAT)
WHERE c.redirect = 0 ORDER BY c.roworder ASC");
if ($smcFunc['db_num_rows']($dbresult) == 0)
fatal_error($txt['downloads_error_no_catexists'] , false);

$context['downloads_cat'] = array();
while($row = $smcFunc['db_fetch_assoc']($dbresult))
{
// Check if they have permission to add to this category.
if ($row['view'] == '0' || $row['addfile'] == '0' )
continue;

$context['downloads_cat'][] = array(
'ID_CAT' => $row['ID_CAT'],
'title' => $row['title'],
);
}
$smcFunc['db_free_result']($dbresult);

$result = $smcFunc['db_query']('', "
SELECT
title, defaultvalue, is_required, ID_CUSTOM
FROM  {db_prefix}down_custom_field
WHERE ID_CAT = " . $cat);
$context['downloads_custom'] = array();
while ($row = $smcFunc['db_fetch_assoc']($result))
{
$context['downloads_custom'][] = array(
'ID_CUSTOM' => $row['ID_CUSTOM'],
'title' => $row['title'],
'defaultvalue' => $row['defaultvalue'],
'is_required' => $row['is_required'],
);
}
$smcFunc['db_free_result']($result);

// Get Quota Limits to Display
$context['quotalimit'] = Downloads_GetQuotaGroupLimit($user_info['id']);
$context['userspace'] = Downloads_GetUserSpaceUsed($user_info['id']);

$context['sub_template']  = 'add_download';

$context['page_title'] = $mbname . ' - ' . $txt['downloads_text_title'] . ' - ' . $txt['downloads_form_adddownload'];

// Check if spellchecking is both enabled and actually working.
$context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && function_exists('pspell_new');

// Needed for the WYSIWYG editor.
require_once($sourcedir . '/Subs-Editor.php');

// Now create the editor.
$editorOptions = array(
'id' => 'descript',
'value' => '',
'width' => '90%',
'form' => 'picform',
'labels' => array(
'post_button' => '',
),
);
create_control_richedit($editorOptions);
$context['post_box_name'] = $editorOptions['id'];


}

function Downloads_AddDownload2()
{
global $txt, $scripturl, $modSettings, $sourcedir, $gd2, $user_info, $smcFunc;

isAllowedTo('downloads_add');

// If we came from WYSIWYG then turn it back into BBC regardless.
if (!empty($_REQUEST['descript_mode']) && isset($_REQUEST['descript']))
{
require_once($sourcedir . '/Subs-Editor.php');

$_REQUEST['descript'] = html_to_bbc($_REQUEST['descript']);

// We need to unhtml it now as it gets done shortly.
$_REQUEST['descript'] = un_htmlspecialchars($_REQUEST['descript']);

}

Title: Re: Download System
Post by: vbgamer45 on May 15, 2012, 10:05:28 PM
Your missing the rest of Downloads_AddDownload2() That is part I am looking for.
Title: Re: Download System
Post by: Texan78 on May 15, 2012, 10:57:47 PM
I've attached the Downloads2.php I found several refrences to AddDownloads2 and createpost function but, I didn't find those together. So not sure where to go from there or what exactly I am looking for or what variable to insert where. Any assistance would be great!

-Thanks!
Title: Re: Download System
Post by: vbgamer45 on May 15, 2012, 10:59:28 PM
File isn't usable there looks like Mac formatting html around everything.
Title: Re: Download System
Post by: Texan78 on May 15, 2012, 11:32:16 PM
Sorry about that, I am on a Mac so tried to save it in a way that could be opened on Windows since I am not sure Windows can open .rtf files from Mac. Try this one now and see you can open it.

-Thanks!
Title: Re: Download System
Post by: vbgamer45 on May 16, 2012, 03:14:29 PM
Updated file attached
Title: Re: Download System
Post by: Texan78 on May 16, 2012, 10:59:50 PM
Thank you so much vbgamer45, that is perfect and exactly what I am looking for. Let me know how I can send you a donation for your help. Just a quick question, what files controls the html, css for how it is posted in a topic? I would like to make a small edit to space some things out, which that I should be able to handled, it's more my speed...LoL Also is the description from the downloads stored in the DB? Just curious because I noticed when you updated the description, it doesn't update the post, just curious. Not a huge deal, just would be nice to update the description and it update the post as well.

-Thanks!
Title: Re: Download System
Post by: vbgamer45 on May 16, 2012, 11:10:51 PM
Quote from: Texan78 on May 16, 2012, 10:59:50 PM
Thank you so much vbgamer45, that is perfect and exactly what I am looking for. Let me know how I can send you a donation for your help. Just a quick question, what files controls the html, css for how it is posted in a topic? I would like to make a small edit to space some things out, which that I should be able to handled, it's more my speed...LoL Also is the description from the downloads stored in the DB? Just curious because I noticed when you updated the description, it doesn't update the post, just curious. Not a huge deal, just would be nice to update the description and it update the post as well.

-Thanks!

For the topic stuff that call is made in Downloads2.php in the AddDownloads2 function under createpost.
If you mean the layout of the template for downloads system that is in themes/default/downloads2.template.php

The description of the downloads is stored in the db in the smf_down_file database table in your forums database.


Have a donation link at http://www.smfhacks.com
You may also want to take a look at Downloads Pro http://www.smfhacks.com/download-system-pro.php
Which has option to add pictures, multifiles per download, and if you edit the description also edits/updates the post of the topic.
Title: Re: Download System
Post by: Texan78 on May 17, 2012, 12:11:51 AM
If you look at the topic...

http://www.weather-connection.com/index.php/topic,19.0.html

I am just trying to put a space between the title, description and link. So that would be in the template file downloads2.template.php right? I also want to update the download link at the top with a download button on the actual downloads page. The button part will be easy.

I will send you a donation for your help this weekend when I get paid. Right now this mod is perfect for my needs even though to have the luxury to edit the description and have it also edit/update the post of the topic would be the only other thing I would need. Maybe if this site makes a little money I can upgrade. Images aren't really a big deal since they can post screen shots in the description.

-Thanks!
Title: Re: Download System
Post by: Texan78 on May 22, 2012, 01:16:34 AM
This is the last thing I need to tweak and then I can officially launch my forum. If you look at the screen shot, what I am trying to do is put a space between the Title, Description, Link when it's posted on a topic.

I looked in downloads2 and Display.template and I can't find where to add the <br /> tag so it puts a space between the two. Any assistance would be very grateful.

Title: Re: Download System
Post by: vbgamer45 on May 22, 2012, 03:31:40 PM
Updated file attached
Title: Re: Download System
Post by: Texan78 on May 24, 2012, 07:57:29 PM
Thank you so much vbgamer45! That is perfect and exactly what I am needing.

I was able to figure out in the template how to change the text out and add a download button instead that I made so it is good to go now.

If you don't mind, could you show me a snippet of the code you edited so I can see exactly what you did and maybe learn what you did? I understand if you can't

-Thanks
Title: Re: Download System
Post by: Texan78 on August 14, 2012, 12:04:44 PM
One other thing I would like to do that I just noticed is set default title to links when the thread is created. When a new download is submitted it creates a topic in a certain section of the forum I choose so there is support for that download. When it creates the link to the download in the topic it is the full URL. How would it be possible to set a default title so instead of it showing like this...

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fwww.mesquiteweather.net%2Fwxconnection%2Fscreenshots%2Fmod_link.png&hash=821cafef079f672007712630814a10636b532c23)

It would show like this with a default link title?

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fwww.mesquiteweather.net%2Fwxconnection%2Fscreenshots%2Fmod_link2.png&hash=ae399f2b75259a084d4a14cf0bb94890fda014ad)

Now I found this in Downloads2.php and tried to change it to this.

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

$showpostlink = '[url=' . $scripturl . '?action=downloads;sa=view;down=' . $file_id . ']Download Script[/url]';


But it doesn't change anything.

How would I go about making that happen? Where do I need to look? Should be as simple as setting the default text correct?

-Thanks
Title: Re: Download System
Post by: Blackburn on August 14, 2012, 05:25:42 PM
Thanks :D
Title: Re: Download System
Post by: vbgamer45 on August 14, 2012, 06:00:21 PM
Quote from: Texan78 on August 14, 2012, 12:04:44 PM
One other thing I would like to do that I just noticed is set default title to links when the thread is created. When a new download is submitted it creates a topic in a certain section of the forum I choose so there is support for that download. When it creates the link to the download in the topic it is the full URL. How would it be possible to set a default title so instead of it showing like this...

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fwww.mesquiteweather.net%2Fwxconnection%2Fscreenshots%2Fmod_link.png&hash=821cafef079f672007712630814a10636b532c23)

It would show like this with a default link title?

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fwww.mesquiteweather.net%2Fwxconnection%2Fscreenshots%2Fmod_link2.png&hash=ae399f2b75259a084d4a14cf0bb94890fda014ad)

Now I found this in Downloads2.php and tried to change it to this.

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

$showpostlink = '[url=' . $scripturl . '?action=downloads;sa=view;down=' . $file_id . ']Download Script[/url]';


But it doesn't change anything.

How would I go about making that happen? Where do I need to look? Should be as simple as setting the default text correct?

-Thanks
There might be more than one place you need to update check all parts for the createpost function.
Title: Re: Download System
Post by: Texan78 on August 14, 2012, 07:56:40 PM
Ok got it sorted out.

That line of code was the correct line that needed to be modified. I replace this...

$showpostlink = '[url]' . $scripturl . '?action=downloads;sa=view;down=' . $file_id . '[/url]';

With this, and then defined the language in the language file.

$showpostlink = '[url=' . $scripturl . '?action=downloads;sa=view;down=' . $file_id . ']' . $txt['link_name'] . '[/url]';

So that issue is done. Would it be possible to place a link on the downloads page of the support topic it creates? If so how would I go about that and where do I need to look?

One more other minor issue. I am trying to rid some errors from my logs and this one is pretty much the only one I am getting.

Quotehttp://www.wxconnection.com/index.php?action=downloads;cat=10
8: Undefined index:
File: /home4/mesquiu0/public_html/wxconnection/Sources/Downloads2.php
Line: 213

Which is this line of code.



'name' => $context['']


Here is the full code with that line.


// Link Tree
$context['linktree'][] = array(
'url' => $scripturl . '?action=downloads;cat=' . $cat,
'name' => $context['']


Looks like the language file isn't defined. Is that correct and if not what should it be or how can I fix that error?

-Thanks!
Title: Re: Download System
Post by: Texan78 on August 17, 2012, 12:06:01 PM
This isn't defined and it is throwing errors in the logs. Whats should it be?

'name' => $context['']

-Thanks

Title: Re: Download System
Post by: vbgamer45 on August 17, 2012, 12:23:19 PM
That part 'name' => $context[''] shouldn't be empty like that it is missing a part.
Title: Re: Download System
Post by: Texan78 on August 18, 2012, 12:43:56 AM
What should it be? It's not defined out of the box.
Title: Re: Download System
Post by: vbgamer45 on August 18, 2012, 10:52:21 AM
It should be

// Link Tree
$context['linktree'][] = array(
'url' => $scripturl . '?action=downloads;cat=' . $cat,
'name' => $context['downloads_cat_name']
);
Title: Re: Download System
Post by: Texan78 on August 18, 2012, 12:30:32 PM
Thank you VB, that appears to have resolved the issue in early testing. I will keep a eye on it and see if the problem arises again.

-Thanks