<?php
defined('COT_CODE') or die('Wrong URL');

$return['success'] = 0;

if(cot_plugin_active('marketorders')) {
  require_once cot_incfile('marketorders', 'plug');

  $msgId = cot_import('msgId', 'P', 'INT');
  $file_id = cot_import('file_id', 'P', 'INT');
  if($msgId > 0 && $file_id > 0 && $usr['id'] > 0) {
    $tmsg = $db->query("SELECT * FROM $db_market_track WHERE t_id=".$msgId.' AND t_touser='.$usr['id'].' LIMIT 1')->fetch();
    $tmsgsub = ($tmsg['t_subid'] > 0 ? $db->query("SELECT * FROM $db_market_track WHERE t_id=".$tmsg['t_subid'].' AND t_oid='.$tmsg['t_oid'].' AND t_status=0 LIMIT 1')->fetch() : array());

    if($tmsgsub['t_id'] > 0) {
      require_once cot_incfile('mavatars', 'plug');
      $mavatar = new mavatar('marketorders', 'msg', $msgId);
      foreach($mavatar->tags() as $mav) {
        if($mav['ID'] == $file_id) {
          $mavatar->delete_mavatar_byid($file_id);
          $return['success'] = 1;
          break;
        }
      }
    }
  }
}

?>
