For the plugin, I did not test it, but it should work (at least it's an starting point). Create a folder called "autopremium" in oc-content/plugins, create a file called index.php on that folder, a nd paste this code :
<?php
/*
Plugin Name: Auto premium
Plugin URI: http://www.osclass.org/
Description: This plugin makes premium ads those without price
Version: 0.1
Author: OSClass
Author URI: http://www.osclass.org/
Short Name: autopremium
Plugin update URI:
*/
function autopremium_post($catId = null, $item_id = null) {
$item = Item::newInstance()->findByPrimaryKey($item_id);
if($item['i_price']==null || $item['i_price']==0) {
Item::newInstance()->update(array('b_premium' => 1), array('pk_i_id' => $item_id));
} else {
Item::newInstance()->update(array('b_premium' => 0), array('pk_i_id' => $item_id));
}
}
// This is needed in order to be able to activate the plugin
osc_register_plugin(osc_plugin_path(__FILE__), '');
// This is a hack to show a Uninstall link at plugins table (you could also use some other hook to show a custom option panel)
osc_add_hook(osc_plugin_path(__FILE__). '_uninstall', '');
osc_add_hook('item_form_post', 'autopremium_post');
osc_add_hook('item_edit_post', 'autopremium_post');
?>