Advertisement:

Author Topic: Repost an expired ad  (Read 27890 times)

Jesse

  • Hero Member
  • *****
  • Posts: 631
  • Out of my mind, back in 5 minutes
Re: Repost an expired ad
« Reply #15 on: January 06, 2012, 09:17:50 am »
Great, that worked!

I hadn't noticed about the images not working until now. I had thought they were being reposted on my other script, but I guess they're not either. That's definitely something to work on.   ::) I'll take a look at it too.

I'm looking right now at the database table os_t_item_resource, which stores images/picture references. I see how pictures are 'attached' to items.
For some reason, when we're reposting an ad, new entries are not being made for the new ad. So somehow we need to write the the "expired" ad photo references to this table for the reposted ad.


Idea
I think if we just implement a new function when the "republish" happens that: Gets all s_name's (photo names) from the os_t_item_resource table for the "expired" ad. Then inserts them back into the same table with the new ad's ID (fk_i_item_id). That would do it. Probably easier said than done though!  :)

Perhaps this could be done with a new database table.... run one function before publishing the new ad, which can read and store the needed photo values and ID of the "expired" ad that we're reposting. Then after the ad is posted, with another function we can then see what the "new" ad's ID is, then go back to our database table and take care of writting the "old" ad's photos values to a new entry into the table os_t_item_resource. ............ otherwise, I'm not sure how we can get both the "old" and "new" ad ID's to do all this. Another alternative would be to modify the add() function within the core file ItemActions.php, which seems even more challenging.



UPDATE: I've been working on my 'idea', and have modified the plugin so it now inserts a needed table. It also will read the expired ad's ID when the user goes to repost. It then can look into the os_t_item_resource table to get the needed information for the photos. That's where I left off... it's now about 5am and I have a dentist appt at 11am, so better get some sleep!  ;) I'm not sure if this is even the best option, so I'll wait to hear if you do anything more tomorrow. I can certainly continue on this tomorrow (Friday).
« Last Edit: January 06, 2012, 03:55:37 pm by Jesse »

trains58554

  • Osclass contributor
  • Hero Member
  • *****
  • Posts: 3642
  • osCanyon, the class of Osclass
Re: Repost an expired ad
« Reply #16 on: January 06, 2012, 06:16:32 pm »
Hi Jesse,

That is kind of the idea I had find the attached images to the old ad and update the table with the new rows for the images. I never thought to use a table. I had tried to get it working but I was never able to get the data loaded but getting the recourses beforehand should work. The only other problem I see if the user decides to delete a picture that was in the old ad I am not sure how it would be handled.

I would be interested in seeing your changes.

Jay

Jesse

  • Hero Member
  • *****
  • Posts: 631
  • Out of my mind, back in 5 minutes
Re: Repost an expired ad
« Reply #17 on: January 07, 2012, 12:07:41 am »
Ok Jay, I will continue work on my solution.  :)

As far as if a user should delete an item on the repost page... this should be easy to overcome. Perhaps the first of my two functions doesn't have to actually read and save any of the expired ad photo entries, that could all be done by the 2nd function (when the database is more up-to-date after the ad is re-posted). I'm sure I can make this all work one way or another!  ;)

trains58554

  • Osclass contributor
  • Hero Member
  • *****
  • Posts: 3642
  • osCanyon, the class of Osclass
Re: Repost an expired ad
« Reply #18 on: January 07, 2012, 12:59:21 am »
I am looking forward to seeing how you are overcoming these issues. :)

Jay

Jesse

  • Hero Member
  • *****
  • Posts: 631
  • Out of my mind, back in 5 minutes
Re: Repost an expired ad
« Reply #19 on: January 07, 2012, 06:40:52 am »
Hey Jay,

Just to update you on where I'm at...

I'm seeing some issues with my "idea", which are similar to some of your concerns. The big issue I see is even with copying over the image/file information to attach to the 'new' ad, if the 'old' ad is deleted, so are those images. Simply making a "copy" of those images would be possible, but that's just not very efficient. The other way that would work to get around this, is updating the table os_t_item_resource and change the item ID which the photo is attached to... but that would essentially remove the photos from the "expired" ad (which actually may not matter).

So back to my original idea... update the "published date". That solves all the photo problems. And if PayPal is enabled, we can just update the PayPal database table to show the ad as being "not paid". I think this would keep things from getting too complicated. Plus, it really is "re-posting" the original ad, which is good for anyone who has bookmarked that particular ad, or is "watching" it. And I'm sure a whole lot of other things I've not even though of.

So I think this will be the new approach.

And by the way... in the course of testing ad postings (and subsequent deletions), I discovered some possible bugs in the PayPal plugin, which I'm sure you'll see my other post on the issues.
« Last Edit: January 07, 2012, 06:42:50 am by Jesse »

trains58554

  • Osclass contributor
  • Hero Member
  • *****
  • Posts: 3642
  • osCanyon, the class of Osclass
Re: Repost an expired ad
« Reply #20 on: January 07, 2012, 07:17:10 am »
Hi Jesse,

I think going back with your original idea is probably best. It will make it easier to alert the user that there item is about to expire. I never thought about just editing the paypal table to tell it this item has not been paid for that would make things simpler.

I just thought of another idea that goes along with this. With just changing the published date it keeps the item down where it was so we could make some changes to the paypal plugin so the user could pay a fee to get his ad back on the top of the list. I am not sure how we would go about getting the existing ad back to the top of the page. Although I am not really sure if we would need this option as if the user wanted a lot of exposure he could just upgrade his ad to a premium ad.

Anyways I agree that your original idea should be the new approach.

Jay

P.S. I saw your post about the paypal errors.

Jesse

  • Hero Member
  • *****
  • Posts: 631
  • Out of my mind, back in 5 minutes
Re: Repost an expired ad
« Reply #21 on: January 07, 2012, 07:56:10 am »
Awesome, I like the new direction.

As for positioning, if that is an issue, I'm guessing it could be resolved by updating a date somewhere, as that seems to be how other things are arranged, so no need to change another plugin (I don't think... just speculating here). Although, isn't the published date how items are arranged to begin with? I think that's how they appear in the user admin panel.

Looking down the road.... once this plugin is working, rather than having a plugin that just does one function, I think it could be a set of "tools" for the user admin panel. One of the recent customizations was to "activate/deactivate" an ad, which could be incorporated. Another requested feature was to be able to mark an ad as "paid". Another is to add a user profile picture. And with that, perhaps a public user profile, such as we have on this forum? All things for later! ....... Just jotting it down now (brainstorming).

trains58554

  • Osclass contributor
  • Hero Member
  • *****
  • Posts: 3642
  • osCanyon, the class of Osclass
Re: Repost an expired ad
« Reply #22 on: January 07, 2012, 08:17:07 am »
The positioning I do not see as an issue but more as another way to profit from the ads maybe. I think the items on both the user pages and the search page are order in descending order by their id. I am not totally sure on that thought.

I like that idea of using this plugin for a set of tools for the user admin panel. As for the public profile they exist in osclass 2.3.0 but currently the only theme that I know of that has support for the profile page is the modern theme. The files you would need to copy from the modern theme to add support to your theme would be user-public-profile.php and the item.php files. Or for the item.php file you could just copy lines 190 to 252 into your current item.php file.

Jay

Jesse

  • Hero Member
  • *****
  • Posts: 631
  • Out of my mind, back in 5 minutes
Re: Repost an expired ad
« Reply #23 on: January 07, 2012, 08:29:22 am »
I did not know that about the modern theme. Nice! I'll definitely check that out sometime. I know it would be easy enough to implement into my modified BCute theme... glad it exists! That explains the forum question about being able to post a user profile pic.  ;)

I'm sure there are all kinds of "tools" that can be added over time. Perhaps with a Admin panel for enabling/disabling which features the user wants.

Jesse

  • Hero Member
  • *****
  • Posts: 631
  • Out of my mind, back in 5 minutes
Re: Repost an expired ad
« Reply #24 on: January 07, 2012, 11:55:29 am »
Ok Jay, I've finished the initial plugin!  ;D

It works very well, at least on my end. I've changed the plugin name and the main function from item_repost to item_republish, so you'll probably have to update the code in your user-item.php page or wherever you had the repost link before.

Right now, this plugin will generate a link "Republish Ad" like it did before. When you click it, it calls a function that will....

1) Get the ID of the item.
2) Update the published date of the item in the database with the current date/time.
3) Check to see if PayPal plugin is installed (it checks for the table t_paypal_publish).
4) If a matching ID is found within the t_paypal_publish table, it will update the paid status from 1 to 0 (unpaid).
5) Lastly, if successful, the script will take you to the item page. If the item needs to be paid for, you'll see the standard paypal page asking you to pay for the ad.


Known issues or items that need attention
  • I know the flash message(s) aren't working. Not sure why, but haven't looked into it too much yet.
  • The way the script redirects the user after step 5 above may not work with Permalinks, so there is probably a better way to do that.


Plugin attached. Note for anyone else trying out this plugin, place the following code where you want the "Republish Ad" link to appear (like on the user-items.php page, etc.)
Code: [Select]
<?php echo republish_url(); ?>
« Last Edit: January 07, 2012, 12:28:17 pm by Jesse »

Luca

  • Hero Member
  • *****
  • Posts: 584
  • CentOs 6.4 - Virtualmin - OSC 3.0 - Custom Theme
Re: Repost an expired ad
« Reply #25 on: January 07, 2012, 03:22:38 pm »
@Jesse @trains58554

Great, it's working superb with permalinks also. Very good job!

Thank you

Luca

Jesse

  • Hero Member
  • *****
  • Posts: 631
  • Out of my mind, back in 5 minutes
Re: Repost an expired ad
« Reply #26 on: January 07, 2012, 03:26:44 pm »
Hi Luca,

Thank you very much for testing it out! It's that's excellent news about permalinks... I just hadn't tested that out yet.  ;D

trains58554

  • Osclass contributor
  • Hero Member
  • *****
  • Posts: 3642
  • osCanyon, the class of Osclass
Re: Repost an expired ad
« Reply #27 on: January 07, 2012, 08:44:41 pm »
Hi Jesse,

It is working very well. Everything is functioning the way I would expect.

As for your issues The reason the flash messages are not showing is due to the way we are redirecting the pages. I have been trying to get the redirection to work off the built in redirection but I have not quite got a link to the right class the class that we have to connect to is the BaseModel class then we can call the redirectTo function.

As for the permalinks it works with permalinks enabled but the urls we are using still show up in the default way. They are not friendly looking or at least not to a user. I think once we get the redirection working right we can work on adding the rules to make our url's friendly.

Jay

Luca

  • Hero Member
  • *****
  • Posts: 584
  • CentOs 6.4 - Virtualmin - OSC 3.0 - Custom Theme
Re: Repost an expired ad
« Reply #28 on: January 07, 2012, 09:06:32 pm »
@trains58554
I would turn out that permalinks feature is not at all a problem, here, because no one needs them (nor search engines, nor users): they merely are a transition, in this case... if you get my idea. Anyway, it's only my opinion  :)

trains58554

  • Osclass contributor
  • Hero Member
  • *****
  • Posts: 3642
  • osCanyon, the class of Osclass
Re: Repost an expired ad
« Reply #29 on: January 07, 2012, 11:33:38 pm »
@rafl

I get what you are saying. The only place it would be nice to have the permalink would be when you redirect the page to the item but it really is not all that necessary.

Jay