Commit info for scoop/struct:
Modified Files:
scoop.sql
Log Message:
Fix for bug #8 Ad renewals are broken. --hulver
Index: scoop.sql
===================================================================
RCS file: /cvs/scoop/scoop/struct/scoop.sql,v
retrieving revision 1.184
retrieving revision 1.185
diff -r1.184 -r1.185
351a352,356
> INSERT INTO blocks VALUES ('ad_submitted_message','<p> Now that you\'ve submitted the ad, it has to be approved. Our crack team of site maintainers who pore over all of the ad submissions daily will notice yours has arrived, and approve it so that it can be displayed on the site. If for some reason they don\'t see fit to approve it, you will get an email sent to your real_email address explaining why.</p>\r\n%%AD_CC_PAY%%\r\n%%AD_PAYPAL_PAY%%\r\n%%AD_FREE_MESSAGE%%','1','This message is displayed when an advert has gone through all the stages of submission, apart from payment, and is waiting to be approved. If the advert needs paying for, then some more message will be displayed at the same time.\r\nIf the total cost of the advert is nothing, then |AD_FREE_MESSAGE| will be replaced by the contents of the block, ad_free_msg. AD_CC_PAY and AD_PAYPAL_PAY will be ignored.\r\nIf the site control ads_use_cc is enabled, then |AD_CC_PAY| will be replaced with the contents of the!
block ad_pay_cc_msg.\r\nIf the site control ads_use_paypal is enable, then |AD_PAYPAL_PAY| will be replaced with the contents of the block ad_pay_paypal_msg.\r\n','advertising','default','en');
> INSERT INTO blocks VALUES ('ad_renewed_message','<p>Thank you for renewing your advert. As it\'s already been approved, you don\'t have to wait. As soon as it\'s paid for, it will appear.</p>\r\n%%AD_CC_PAY%%\r\n%%AD_PAYPAL_PAY%%\r\n%%AD_FREE_MESSAGE%%','1','This message is displayed when an advert has gone through all the stages of renewal, apart from payment. As renewals don\'t need approving, the advert will appear as soon as it is paid for. If the advert needs paying for, then some more messages will be displayed at the same time.\r\nIf the total cost of the advert is nothing, then |AD_FREE_MESSAGE| will be replaced by the contents of the block, ad_free_msg. AD_CC_PAY and AD_PAYPAL_PAY will be ignored.\r\nIf the site control ads_use_cc is enabled, then |AD_CC_PAY| will be replaced with the contents of the block ad_pay_cc_msg.\r\nIf the site control ads_use_paypal is enable, then |AD_PAYPAL_PAY| will be replaced with the contents of the block ad_pay_paypal_msg.\r\n','a!
dvertising','default','en');
> INSERT INTO blocks VALUES ('ad_pay_cc_msg','<p>%%norm_font%%<a\r\nhref=\"%%secure_site_url%%%%rootdir%%/special/adpay?type=cc%%payment_args%%\"><img\r\nsrc=\"%%imagedir%%/cclogos.gif\" width=\"87\" height=\"27\"\r\nborder=0 ALT=\"%%sitename%% accepts Visa and MasterCard\"><br>Pay with Visa or Mastercard</a>%%norm_font_end%%</p>','1','This message is displayed as part of the advert submission process. See the block ad_submitted_message for more information on where it will appear.\r\nThere are three special variables concerned with this. |num_impressions| will be replaced by the number of impressions ordered.\r\n|price| will be replace by the total cost of the order.\r\n|payment_args| must be present somewhere in the link url to correctly pass arguments to the payment method.','advertising','default','en');
> INSERT INTO blocks VALUES ('ad_pay_paypal_msg','<p>%%norm_font%%<a\r\nhref=\"%%secure_site_url%%%%rootdir%%/special/adpay?type=paypal%%payment_args%%\"><img\r\nsrc=\"%%imagedir%%/paypal.gif\" width=\"87\" height=\"27\"\r\nborder=0 ALT=\"Pay with Paypal\">Pay with Paypal</a>%%norm_font_end%%</p>','1','This message is displayed as part of the advert submission process. See the block ad_submitted_message for more information on where it will appear.\r\nThere are three special variables concerned with this. |num_impressions| will be replaced by the number of impressions ordered.\r\n|price| will be replace by the total cost of the order.\r\n|payment_args| must be present somewhere in the link url to correctly pass arguments to the payment method.','advertising','default','en');
> INSERT INTO blocks VALUES ('ad_free_msg','<p>This ad is free, you don\'t have to pay for it.','1','This message is displayed as part of the advert submission process. See the block ad_submitted_message for more information on where it will appear.\r\nThere are two special variables concerned with this. |num_impressions| will be replaced by the number of impressions ordered.\r\n|price| will be replace by the total cost of the order.','advertising','default','en');
392d396
< INSERT INTO box VALUES ('submit_ad_pay_box','Ad Submitted','my $content = qq{\r\n<p> Now that you\'ve submitted the ad, it has to be approved. Our crack team of site maintainers who pore over all of the ad submissions daily will notice yours has arrived, and approve it so that it can be displayed on the site. If for some reason they don\'t see fit to approve it, you will get an email sent to your real_email address explaining why.</p>\r\n<p> But wait! There\'s more! Your ad will not be approved until it has been paid for. Depending on how we do payment, that could be sooner or later.</p>\r\n<p> Thanks for advertising with %%sitename%% </p>\r\n};\r\n\r\nreturn { content => $content };','This generates the page the user will see when they have successfully submitted an ad. This should direct them on how to pay for the ad, and\r\nexplain the details of what will happen now. ','box',0);
405d408
< INSERT INTO box VALUES ('unpaid_ad_reap','','my ($rv, $sth) = $S->db_delete({\r\n FROM => \'ad_info\',\r\n WHERE => \'paid is null and TO_DAYS(NOW()) - TO_DAYS(submitted_on) >= 14 and example != 1\'});\r\n$sth->finish();\r\n','Reap unpaid ads after 14 days. They are unlikely to ever be paid for then.','blank_box',0);
413a417,418
> INSERT INTO box VALUES ('unpaid_ad_reap','','my ($rv, $sth) = $S->db_delete({\r\n FROM => \'ad_info\',\r\n WHERE => \'paid is null and TO_DAYS(NOW()) - TO_DAYS(submitted_on) >= 14 and example != 1 and purchase_price > 0\'});\r\n$sth->finish();\r\n','Reap unpaid ads after 14 days. They are unlikely to ever be paid for then.','blank_box',0);
> INSERT INTO box VALUES ('submit_ad_pay_box','Ad Submitted','my $action = $ARGS[0];\r\nmy $ad_id = $ARGS[1];\r\n\r\nmy $q_id = $S->dbh->quote($ad_id);\r\nmy ($num, $price);\r\nmy $args;\r\nmy $content;\r\n\r\nif ($action eq \'renew\') {\r\n $num = $ARGS[2];\r\n unless ($num) {\r\n return \'Error! No impression count was submitted.\';\r\n }\r\n # Get total price\r\n my ($rv, $sth) = $S->db_select({\r\n WHAT => \'ad_types.cpm\',\r\n FROM => \'ad_info, ad_types\',\r\n WHERE => \"ad_info.ad_id = $q_id AND ad_info.ad_tmpl =\r\nad_types.type_template\"\r\n });\r\n my ($cpm) = $sth->fetchrow();\r\n $price = ($num/1000) * $cpm;\r\n $args=\";ad_id=$ad_id;renew=1;count=$num\";\r\n $content = $S->{UI}->{BLOCKS}->{ad_renewed_message};\r\n} else {\r\n my ($rv, $sth) = $S->db_select({\r\n WHAT => \'purchase_size, purchase_price\',\r\n !
FROM => \'ad_info\',\r\n WHERE => \"ad_id=$q_id\"});\r\n\r\n ($num, $price) = $sth->fetchrow();\r\n $sth->finish();\r\n $args=\";ad_id=$ad_id\";\r\n $content = $S->{UI}->{BLOCKS}->{ad_submitted_message};\r\n}\r\n\r\nmy ($pay_cc_block, $pay_pal_block, $pay_free_block);\r\n\r\n$price = sprintf(\"%1.2f\", $price);\r\nif ($price ne \'0.00\') {\r\n $pay_cc_block = $S->{UI}->{BLOCKS}->{ad_pay_cc_msg} if ($S->{UI}->{VARS}->{ads_use_cc});\r\n $pay_pal_block = $S->{UI}->{BLOCKS}->{ad_pay_paypal_msg} if ($S->{UI}->{VARS}->{ads_use_paypal});\r\n} else {\r\n $pay_free_block = $S->{UI}->{BLOCKS}->{ad_free_msg};\r\n #// update the advert here for number of impressions.\r\n if ($action eq \'renew\') {\r\n $S->cc_finish_renewal($ad_id, \'\', 0, \'free\', $num);\r\n } else {\r\n $S->cc_finish_ad_sale($ad_id, \'\', 0, \'free\');\r\n }\r\n}\r\n$content =~ s/%%AD_CC_PAY%%/$pay_cc_block/;\r\n$content =~ s/%%AD_PAYPAL_PAY%%/$pay_pal_block/;\r\n$co!
ntent =~ s/%%AD_FREE_MESSAGE%%/$pay_free_block/g;\r\n$content !
=~ s/%%n
um_impressions%%/$num/g;\r\n$content =~ s/%%price%%/$price/g;\r\n$content =~ s/%%payment_args%%/$args/g;\r\n\r\nreturn { content => $content };\r\n','This generates the page the user will see when they have successfully submitted or renewed an ad. If they still need to pay for the advert it will display the various payment options, depending on the ads_use_cc and ads_use_paypal vars. If the advert is free, it will call the relevent functions to mark it as paid. Depends on the blocks ad_renewed_message, ad_submitted_message, ad_pay_cc_msg, ad_pay_paypal_msg & ad_free_msg','box',0);
830a836
> INSERT INTO patches VALUES ('1_0-dev',28,'AdRenewal','sql');