Author Topic: [SOLVED] New items request: pay for post in a specific board  (Read 7820 times)

Offline monotiz

[SOLVED] New items request: pay for post in a specific board
« on: April 27, 2007, 01:20:24 am »
Hi. I'm italian. Sorry for my english.
I'm newbie in php language.
   
I would want to modify the code SMFShop so that, opening a new topic in a specific board, to the customer in issue they come embezzled a sure number of credits.

Thanks.  O0

Offline monotiz

Re: New items request: pay for post in a specific board
« Reply #1 on: April 27, 2007, 04:56:15 pm »
I've found this code in Post.php

Code: [Select]
// If we do give credits...
if (isset($row_shop['countMoney']) && $row_shop['countMoney'] == "1") {
// New topic?
if ($newTopic)
$points = $modSettings['shopPointsPerTopic'];
else
$points = $modSettings['shopPointsPerPost'];

I could specify the number of the board in order to remove credits every new topic ...

Offline feeble

Re: New items request: pay for post in a specific board
« Reply #2 on: April 28, 2007, 09:24:18 pm »
just check it to this, should work, but hasnt been tested, so let me know if there is a problem

ive added is  && in_array($board, array(1,3,4))
this will only let topic count as money if created in boards1,3 or 4
change as you wish

   
tradotto ad italiano: controllo giusto a questo, dovrebbe funzionare, ma hasnt esaminato, in modo da lasciarlo sanno se ci è un problema il ive aggiunto è && in_array ($board, allineamento (1.3.4)) ciò soltanto ha lasciato il conteggio di soggetto come soldi se generato in boards1,3 o in 4 cambiare come desiderate


in Post.php
Code: [Select]
// If we do give credits...
if (isset($row_shop['countMoney']) && $row_shop['countMoney'] == "1") {
// New topic?
if ($newTopic && in_array($board, array(1,3,4)))
$points = $modSettings['shopPointsPerTopic'];
else
$points = $modSettings['shopPointsPerPost'];

Offline monotiz

Re: New items request: pay for post in a specific board
« Reply #3 on: April 28, 2007, 10:47:37 pm »
just check it to this, should work, but hasnt been tested, so let me know if there is a problem

ive added is  && in_array($board, array(1,3,4))
this will only let topic count as money if created in boards1,3 or 4
change as you wish
Thanks for reply and for italian translate.
   
with this modification, specific which board it increases the credits, but not in which board decrement… or mistake?

Offline feeble

Re: New items request: pay for post in a specific board
« Reply #4 on: April 28, 2007, 11:11:37 pm »
not really that advaned, as im still unsure exactly what boards and what you want each board to add or deduct.

atm all it does is allow certain board to receive credits for a topic defined by the amount of credits in your SMFShop admin.

   
Traduzione italiana: non realmente quello advaned esattamente, come im incerto ancora che bordi e che cosa desiderate ogni bordo aggiungere o dedurre. l'atmosfera tutta è permette che il bordo sicuro ricevi gli accreditamenti per un soggetto definito dall'importo degli accreditamenti nel vostro SMFShop admin.

Offline monotiz

Re: New items request: pay for post in a specific board
« Reply #5 on: April 28, 2007, 11:27:53 pm »
finally I have understood. Then, thanks a lot. The modification works therefore:
I have put -10 credits for every as an example new topic and +10 credits for every new post. Who opens a new one topic in the board indicated in the code, loses 10 credits… fantastic.

Thanks still.  O0

Offline preddy25

Re: [SOLVED] New items request: pay for post in a specific board
« Reply #6 on: April 29, 2007, 12:48:32 am »
thats a good idea , i going to implement it in some posts for classified or something ..but what happens if the user has zero credits? does it just go negative? or will it stop user from posting

Offline monotiz

Re: [SOLVED] New items request: pay for post in a specific board
« Reply #7 on: April 29, 2007, 12:52:04 am »
thats a good idea , i going to implement it in some posts for classified or something ..but what happens if the user has zero credits? does it just go negative? or will it stop user from posting
I have test this case.

The user's credits stop on 0 credits but he can open new topic...

A control would go fact..

Offline feeble

Re: [SOLVED] New items request: pay for post in a specific board
« Reply #8 on: April 29, 2007, 07:40:34 am »
thats a good idea , i going to implement it in some posts for classified or something ..but what happens if the user has zero credits? does it just go negative? or will it stop user from posting
I have test this case.

The user's credits stop on 0 credits but he can open new topic...

A control would go fact..

Code: [Select]
if ($newTopic && in_array($board, array(1,3,4)) && ($row2['money'] > 10))
the  > 10 is there as your topics are worth 10 each

please realise that its not actually a good idea to implement this if you are planning on doing this for everything board, as its easier to go into the SMFShop admin.

but do this if you only want it on a few boards.

Offline monotiz

Re: [SOLVED] New items request: pay for post in a specific board
« Reply #9 on: April 29, 2007, 09:38:19 am »

Code: [Select]
if ($newTopic && in_array($board, array(1,3,4)) && ($row2['money'] > 10))
the  > 10 is there as your topics are worth 10 each

please realise that its not actually a good idea to implement this if you are planning on doing this for everything board, as its easier to go into the SMFShop admin.

but do this if you only want it on a few boards.
Thanks, but this not resolv the problem of 0 credits...

Offline feeble

Re: [SOLVED] New items request: pay for post in a specific board
« Reply #10 on: April 29, 2007, 10:02:50 am »
apologies i was thinking about it the wrong way.

im looking into it, and just need to work out a "smart" way to do this. ill get back to you

Offline feeble

Re: [SOLVED] New items request: pay for post in a specific board
« Reply #11 on: April 29, 2007, 10:27:46 am »
ok, now before you alter this, i dont recommend unless daniel15 oks it, since he knows more about SMF coding guidelines.

annyways, open up Sources/Security.php
AGAIN I DONT RECOMMEND, UNLESS DANIEL15 OKS
find
Code: [Select]
// Administrators are supermen :P.
if ($user_info['is_admin'])
return true;

// Are we checking the _current_ board, or some other boards?
replace with
Code: [Select]
// Administrators are supermen :P.
if ($user_info['is_admin'])
return true;

$temp = is_array($permission) ? $permission : array($permission);
if(in_array('post_new', $temp))
{
$row= mysql_fetch_assoc(db_query("
SELECT money
FROM {$db_prefix}members
WHERE ID_MEMBER = {$ID_MEMBER} LIMIT 1", __FILE__, __LINE__));
if($row['money'] < 10)
return false;
}

// Are we checking the _current_ board, or some other boards?

Offline monotiz

Re: [SOLVED] New items request: pay for post in a specific board
« Reply #12 on: April 29, 2007, 05:37:41 pm »
You are a genius! There is a way in order to repay to you?  O0

Offline preddy25

Re: [SOLVED] New items request: pay for post in a specific board
« Reply #13 on: May 01, 2007, 01:09:44 am »

is this code for specific boards like the ones u posted above ?1 ,3,4 ? do u we use the same?






ok, now before you alter this, i dont recommend unless daniel15 oks it, since he knows more about SMF coding guidelines.

annyways, open up Sources/Security.php
AGAIN I DONT RECOMMEND, UNLESS DANIEL15 OKS
find
Code: [Select]
// Administrators are supermen :P.
if ($user_info['is_admin'])
return true;

// Are we checking the _current_ board, or some other boards?
replace with
Code: [Select]
// Administrators are supermen :P.
if ($user_info['is_admin'])
return true;

$temp = is_array($permission) ? $permission : array($permission);
if(in_array('post_new', $temp))
{
$row= mysql_fetch_assoc(db_query("
SELECT money
FROM {$db_prefix}members
WHERE ID_MEMBER = {$ID_MEMBER} LIMIT 1", __FILE__, __LINE__));
if($row['money'] < 10)
return false;
}

// Are we checking the _current_ board, or some other boards?

Offline monotiz

Re: [SOLVED] New items request: pay for post in a specific board
« Reply #14 on: May 01, 2007, 01:45:40 am »
1, 3, 4 is an example. You must specify your board. You must replace to code: one in Post.php and one in Security.php.