masterdxb / sweetcron

Automatically exported from code.google.com/p/sweetcron
0 stars 0 forks source link

Return empty item to not add item to db #28

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
to help filter items before adding to the db, allow plugins to return an empty 
item if they do not 
want the item added to the db.

e.g. a twitter_com plugin could be created that filters twitters that begin 
with an '@' mark, returning 
an empty item so that twitter replies do not get added to the db.

Original issue reported on code.google.com by yongf...@gmail.com on 29 Aug 2008 at 5:46

GoogleCodeExporter commented 8 years ago
I've added this to my own install:

In system/application/models/item_model.php find the following function: 
function add_item($item = NULL)

In this function above the following line: $this->db->insert('items', $item);

Add this: 

if ($item->item_title == NULL) {
    return;
}

Or use my attached version!

Original comment by admin%so...@gtempaccount.com on 29 Aug 2008 at 4:57

Attachments:

GoogleCodeExporter commented 8 years ago
so if i don't want to have my '@' replies to go on the items, what exactly 
should i
do? thanks

Original comment by amm...@gmail.com on 31 Aug 2008 at 10:22

GoogleCodeExporter commented 8 years ago
I think I'm going to discourage outright prevention of importing stuff.  We'll 
see where we go.

For now, I think the best approach is to set the item as draft.  So in your 
plugin, you can write simply

$item->item_status = 'draft';

however, to use this you will need to get the latest version of Sweetcron 
source from the code repository, or wait 
for v1.08 (I recommend waiting).

Original comment by yongf...@gmail.com on 31 Aug 2008 at 12:34

GoogleCodeExporter commented 8 years ago
Thanks man!! much appreciated!

Original comment by amm...@gmail.com on 31 Aug 2008 at 4:55